Undefined index error while using $_FILES in PHP and JQuery -


I create a file upload using 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.

This is my 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;   

This is my 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}}; });   

This is my 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; }}}}}   

I do not know what the error is and why it is coming.

You are not sending data to $ _ FILES , but in fact $ _ POST .

Note your $. In the AJAX () call parameter: data: {'file': name}

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -