Image upload with PHP returning an error: undefined index error

2

Good evening everyone, I am using a script that I have and I have always used to upload images only when I choose some images it returns the error undefined index error

The only problem is that in 80% of cases it works normal I did a var dump of $ _FILES to see what happens

in the normal case

array (size=1)
  'foto' => 
    array (size=5)
      'name' => string 'interlogo.jpg' (length=13)
      'type' => string 'image/jpeg' (length=10)
      'tmp_name' => string 'C:\wamp\tmp\php586.tmp' (length=22)
      'error' => int 0
      'size' => int 13800

In case of error

array (size=0)
  empty

The only difference from one photo to another is the size, one has 130k and another 3 mega. when it gives the error it does well in the rows of the variables

$foto_name=$_FILES["foto"]["name"];
$foto=$_FILES["foto"]["tmp_name"];  

Has anyone ever had this error?

    
asked by anonymous 05.10.2016 / 03:25

1 answer

1

Your problem may be with the post_max_size directive of php.ini .

According to documentation :

  

[...] If the posted data is larger than post_max_size then the   variables superglobals $_POST and $_FILES will empty. [...]

It is also worth checking the upload_max_filesize directive, since in order to upload large files, max_post_size must be greater than upload_max_filesize .

    
05.10.2016 / 20:23