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.
You should check if you have something meaningful in $_SERVER, $_REQUEST, etc... Also, check the log produced by the class.
I don't have time to try using jQuery for the upload, but your example seems quite too simple compared to the code samples given on these links.
I would suggest not using jQuery for the upload case (as in this case, jQuery complicates the code), or else trying out the code samples providing in the link above.Reply
Re: How to use jQuery ajax instead of XMLHttpRequest new!
// 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!
Thank you all.
my html code
my js code
my php code
output > error : Can't read image source. Not an image?.
I don't have time to try using jQuery for the upload, but your example seems quite too simple compared to the code samples given on these links.
I would suggest not using jQuery for the upload case (as in this case, jQuery complicates the code), or else trying out the code samples providing in the link above.
i'm passing 'file name'. it can be passed through header. ( X-File-Name )
can you explain "xhr.send(f)" on your js script? why you pass 'f'?
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.