I have a question again. I wanted to know it is possible that I send pictures via AJAX to a PHP file. what am I supposed to write the data into images arrive as an image rather than text
<form onsubmit="sendWithAjax()">
<label>File:
<input name="myfile" type="file" size="30" />
</label>
<input type="submit" name="submitBtn" class="sbtn" value="Upload" />
</form>
sendWithAjax(e) {
e.preventDefault();
jQuery.ajax({
type: "POST",
url: "upload.php",
data: ? ? ?
});
}
You cannot send data (file,image) to server via AJAX directly.
You must use some frameworks like: http://www.plupload.com/, http://valums.com/ajax-upload/, or you can read more here -> http://www.webdeveloperjuice.com/2010/02/13/7-trusted-ajax-file-upload-plugins-using-jquery/
You can use uploadify to send pictures to a particular PHP page to elaborate them.
There's various ready-made plugins on doing file upload on jquery.
Doing this kind of uploading hacks is not an enjoyable experience, so people enjoy using ready-made solutions.
Here're a few:
http://www.webmotionuk.co.uk/jquery-image-upload-and-crop-for-php/
http://www.phpletter.com/Demo/AjaxFileUpload-Demo/
You can search more from jquery's plugin -site.