0

Possible Duplicate:
How can I upload files asynchronously with jQuery?
jQuery Ajax File Upload

I use $.post to send my form data to a php page for adding to database. I wanted to know can I use the same way to upload files? or I have to use JQuery plugins for doing that? here is my code:

$.post("demo.php",{name:$("#name").value,family:$("#family").value},function(result){
   $("#message").html(result);
});
Community
  • 1
  • 1
H Emad
  • 329
  • 8
  • 19

2 Answers2

1

I'm not 100% sure about uploading a file via the post command using jQuery, but frankly it's just easier to use a plugin that can also handle cool HTML 5 support like drag and drop. One that I found worked really well is https://github.com/blueimp/jQuery-File-Upload

And it's under the MIT license, so you should be good in that perspective.

Basil Al-Dajane
  • 427
  • 6
  • 16
1

No. You can't manage asynchronous file upload using $.post

Use a plugin instead, I have used Blueimp and it gave me good results.

davidaam
  • 443
  • 1
  • 8
  • 17