Upload an image with AJAX

To begin, little reminder about sending a form (without upload) AJAX with jQuery.



Nothing less than a form for sending in AJAX.
Here in this example will be about an upload image, but can be adapted to any other type of file. Here is the code that supports the upload of an image, in addition to the rest of the form.

enctype added = "multipart / form-data" to the form is mandatory if you want to do a file upload. We also add our field that allows the user to select a file on his computer. It states that only the images are accepted.

The upload AJAX is related in fact to support the browser FormData API. This is supported by the major browsers
finaly PHP :
You can use my other tutoriel to handle this php file .

Comments

Popular posts from this blog

Twitter API with PHP

Realtime Chat Application with CakePHP and Socket.IO #1

Let's build a mobile application with Ionic Framework #3