2

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?

2
  • 2
    Did you search here first before asking? Commented Jun 29, 2012 at 16:22
  • Its not possible to send form/multipart data via ajax Commented Jun 29, 2012 at 16:25

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

Comments

1

Use the jquery.form plugin....

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.