Reputation: 437
I am using PHP and I need to upload an image using AJAX.
Can anyone help me out how to achive this?
Upvotes: 0
Views: 678
Reputation: 1511
The only browser I know that 100% allows AJAXing of files, are gecko based browsers(Firefox). See FormData Objects, older versions allow for you to read files and transmit them through a body, though depending on the file size, could take a lot of memory. FormData objects fix this method.
Upvotes: 0
Reputation: 2670
As far as I know you can't really do this with AJAX. Most people post the upload to hidden iframes and make it look ajaxy. There are lots of libraries that help you do this. I googled and found:
http://valums.com/ajax-upload/
but i havent used it. There are lots of similar ones, so it should be easy to find one to suit your needs.
If you want to use all custom code you should be able to find tutorials on that, but like I said it should just be a matter of posting to an iframe and doing a callback when it completes.
Upvotes: 1
Reputation: 23016
There are 384,000 results in Google for "PHP ajax image upload"
Here is the link for the first result.
Upvotes: 5