-2

Here is Php Codeenter image description here

And Here html code enter image description here

i get this type of error "Notice: Undefined index: file in C:\xampp\htdocs\mobile-shope\reg.php on line 12" can any one solve it.

  • 2
    Place your code into the question, and don't make images you link to, if you want help. – gview Oct 25 '20 at 15:40
  • Looks like `$_FILES['file']['name']` isn't actually set. Did you set `enctype="multipart/form-data"` on your `
    ` tag? Double check what your name on the file upload input is as well.
    – jshrc Oct 25 '20 at 15:41
  • Basically, you have a bunch of form fields your php script is looking for. If you submit a form where those fields either don't exist or have no value, then the $_POST will not contain those array elements. Thus you get the warning. A warning is not necessarily an error, but good coding would probably have a validation routine that would insure the form data includes all the elements required. – gview Oct 25 '20 at 15:44
  • Does this answer your question? ["Notice: Undefined variable", "Notice: Undefined index", and "Notice: Undefined offset" using PHP](https://stackoverflow.com/questions/4261133/notice-undefined-variable-notice-undefined-index-and-notice-undefined) – Progman Oct 25 '20 at 20:11

1 Answers1

0

Please make sure that:

  • file_uploads = On in your php.ini file.
  • You have added enctype="multipart/form-data" in your html form.

Also try to debug it by using print_r($_FILES);

For more information, checkout this: https://www.w3schools.com/php/php_file_upload.asp

Thanks,

Parminder Singh
  • 351
  • 1
  • 10