php - Getting an error file_get_contents(): Filename cannot be empty . in line193 WHILE UPLOADING EXCEL SHEET

Getting the following error when running my PHP script:

file_get_contents(): Filename cannot be empty  .  in line193

The script:

$zip = new ZipArchive();
$zip->open($zip_name,  ZipArchive::CREATE);
//LINE  193:
foreach ($img_data as $key => $file) {
    $zip->addFromString(basename($file),  file_get_contents($file, FALSE, $context)); 
}
$zip->close();

Answer

Solution:

Sounds like $file is blank or null.

Which leads back to $img_data.

The way it is written, $img_data should have the form [$key] = > $filename

Before line 193, insert your own debug code:

print_r($img_data);

See what that produces, and work backwards from there.

Source