Undefined index error while using $_FILES in PHP and JQuery -
I create a file upload using This is my This is my This is my I do not know what the error is and why it is coming. You are not sending data to Note php and
jquery I've been, I've created a submit button without having to But everything is working fine but there is only one error that shows me the undefined message.
html
& lt; Div id = 'show' & gt; & Lt; / Div & gt; & Lt; Form action = 'demo.php' method = 'POST' encrypt = 'multipart / form-data' & gt; & Lt; Input type = 'file' id = 'file' name = 'file' & gt; & Lt; / Form & gt;
jquery :
$ (document) .ready (function () {$ ('# file' '' '(' Name '); $ .ajax ({url:' demo.php ', type:' post ', data: {' file ': name}, before: function () {$ (' # show '). Html (' Loading ... ');} Success: Function (Data) {$ (' # Show '). Html);}}); Description is False}}; });
php code:
if (isset ($ _ files ['file'])) {$ File = $ _FILES ['file']; // file property $ file_name = $ file ['name']; $ File_tmp = $ file ['tmp_name']; $ File_size = $ file ['size']; $ File_error = $ file ['error']; // extension $ file_ext = explosion ('.', $ File_name); $ File_ext = strtolower (end ($ file_ext)); $ Permission = array ('jpg', 'png'); If (in_array ($ file_ext, $ is allowed)) {if ($ file_error === 0) {if ($ file_size & lt; = 2097152) {$ new_file = uniqid ('', true) '.' . $ File_ext; $ File_destination = 'Upload /' $ New_file; If (move_uploaded_file ($ file_tmp, $ file_destination)) {echo $ file_destination; }}}}}
$ _ FILES , but in fact
$ _ POST .
your
$. In the AJAX () call parameter:
data: {'file': name}
Comments
Post a Comment