I want to send the post data from an input like this:
<input type="file" name="userFile" id="userFile"/>
?
I need to send it via ajax using $.post to a specified file.
How can I do this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Without HTML5, this isnt possible, and the html5 solution won’t work in all browsers without workarounds for browsers that don’t support it.
The most cross-browser way to solve this is to not use ajax and to instead post to a hidden iframe.
Or use a plugin such as uploadify.
Most if not all of the jQuery plugins that implement this use either flash or hidden iframes when the html5 method isn’t supported.