class.upload.php is a powerful and mature PHP class to manage uploaded files, and manipulate images in many ways. The script is available under a GPL license.
// xhr example
var xhr_file = null;
document.getElementById("xhr_field").onchange = function () {
xhr_file = this.files[0];
xhr_parse(xhr_file, "xhr_status");
}
document.getElementById("xhr_upload").onclick = function (e) {
e.preventDefault();
xhr_send(xhr_file, "xhr_result");
}
As I said before, if you want to use jQuery, it is more complicated, as you need access the XHR object, which jQuery doesn't publicly allow.
Again, please check the 5 top results here, these links explain how to make it work with a jQuery form, and provide code samples, as well as interesting discussions about different jQuery versions and browser compatibility.Reply
Re: How to use jQuery ajax instead of XMLHttpRequest new!
The basic JS code for the XHR upload is:
As I said before, if you want to use jQuery, it is more complicated, as you need access the XHR object, which jQuery doesn't publicly allow.
Again, please check the 5 top results here, these links explain how to make it work with a jQuery form, and provide code samples, as well as interesting discussions about different jQuery versions and browser compatibility.
Happy to say this... i could upload an image asynchronusly without using XMLHttpRequest.
use this amazing plugin. http://malsup.github.io/jquery.form.js
example:
Again thank you very much for the code.