Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
293 views
in Technique[技术] by (71.8m points)

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();
question from:https://stackoverflow.com/questions/65879344/getting-an-error-file-get-contents-filename-cannot-be-empty-in-line193-whil

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...