Ajax FormData file upload not working [JQuery] [PHP] -
My upload form is not working for any reason, when I run the form PHP file and my $$$ FILES The variable is empty. I have been trapped for hours and I think I have gone through every post on this site and I do not understand what is happening.
HTML
& lt; form id = "uploadform" name = "uploadform" method = "POST" encrypt = "multipart / form-data" & gt; & Lt; Input id = "actual upload" name = "actual upload" type = "file" multiple /> & Lt; Input id = "upload upload" type = "submit" value = "upload" / & gt; & Lt; / Form & gt; Click the JQuery
$ ('# uploadsubmit') (function (e) {e.preventDefault (); $ .ajax ({Type: "Post", url: "upload.php", data: function () {warning ("test"); var data = new form data (); data .append ("realupload", jquery ("# realupload") (0) .file [0]; return data;}, process data: wrong, content type: wrong, cache: wrong, success: work (data) {$ ('# innercontent'). Html ;}, Error: function () {$ ('# internal content'). Html ("error, help");}});}}); PHP (upload.php)
& lt ;? php //upload.php if (isset ($ _ files ["actual upload"])) {echo "successfully uploaded" $ _FILES ["realupload"] ["error"]; } And {resonate "files not set"; }? & Gt; - The PHP file is just a test file to check if the upload is done
- Never set the output files
- Warning is not run in the AJAX data function, I'm not sure that it should be
- Trying to create a multi file uploader
Could it be Do with the server? There has already been uploaded to a forum which allows to upload itself, so I do not think this is the case, but I'm not sure.
Thank you!
Edit: Friends, thanks for the link, but now you can upload files with HTML5 and XmlHttpRequest2 objects and I'm trying to understand it.
It is not possible to upload a file using AJAX.
You have to use an iframe to upload files. Therefore, you can use the iframe for asynchronous uploads (like AJAX, but its not ajax).
Comments
Post a Comment