views:

192

answers:

1

Hi, I would like to know if its possible to make an AJAX post request to submit a file path to a form. Basically, I want to know if its possible to simulate the path a normal input type="file" would create, but in an AJAX request. Also, is it possible for that link to be pointing to a file on another website?

I think I have no other choice since I don't have access to server-side scripts (PHP), and that is because what I want to create is a greasemonkey script (userscript).

Thanks for answers.

A: 

I think I have no other choice since I don't have access to server-side scripts (PHP), and that is because what I want to create is a greasemonkey script (userscript).

Javascript/jQuery can only help you to send the request to server but you will need the server-side language to actually upload the file. It is not possible otherwise.

However, have a look at jQuery Form Plugin.

Sarfraz
I know, I do not wish to upload it with javascript, I want to make a request containing the file path to the server (which already has the code to upload the file). Maybe it is possible to specify a path to a input type="file" in another way?
Joel Robichaud
@Joel Robichaud: For security reasons, you can not prefill its value, you do have to click on the browse button and then select the file after which it will be filled with file path.
Sarfraz
Thank you for your replies, and also thank you for the jQuery Form Plugin link, I will check it out.
Joel Robichaud
@Joel Robichaud: You are welcome :)
Sarfraz