Upload Csv with php error: Undefined offset: [closed]

0

Good morning. I am uploading csv with php, it does the rendering but it gives the following error: "Undefined offset:" I can not identify this error and try ... Help me! ..

    
asked by anonymous 01.10.2018 / 14:53

1 answer

0

The " Undefined offset " error usually happens when you are trying to do some operation with the nonexistent value of an array.

In CSV files (or excel) sometimes comes empty rows and columns, which he understands as being part of a file (even though it has no value). So before you perform explodes , or other operations, it is always good to test if the value of the array actually exists:

if (isset($_FILES['file']['name']) && !empty($_FILES['file']['name'])) { [...] }
    
01.10.2018 / 17:33