-1

Some of the zip files is download but some files showing like "The requested URL /export/1286.zip was not found on this server."

But i am using the same code for both.

final_zip($certificate_id);
function final_zip($certificate_id){

$zip = new ZipArchive;
$zip_file=$certificate_name.'-licence-documents-'.date("d-m-Y h:i:s").'.zip';

if ($zip->open("$zip_file",ZipArchive::CREATE) === TRUE){

$q_pack="(select * from filename where cerid=$id)";
$res_pack = db_query($q_pack);
if ($res_pack){

$fp = fopen('Package_list.csv', 'w');
while ($pack_row = db_fetch_object($res_pack))
{fwrite($fp, "\n");
foreach ($pack_row as $line) {
$val = '"'.$line.'"'.',';
fwrite($fp, $val);}}

fclose($fp);

$zip->addFile('Package_list.csv', "Package list.csv");

}}$zip->close();
ob_get_clean();

header('Content-Type: application/zip');
header("Content-Disposition: attachment; filename=$zip_file");
header('Content-Length: ' . filesize($zip_file));
header("Location: $zip_file");}

And also please find the screenshor of the errorError

Priya
  • 51
  • 6

1 Answers1

0

I saw the your zip file have space, so when create the name please remove all space.

Base on your code you can change as:

$zip_file=$certificate_name.'-licence-documents-'.date("d-m-Y h:i:s").'.zip';

To

$zip_file=$certificate_name.'-licence-documents-'.date("d-m-Yh:i:s").'.zip';

or

$zip_file=$certificate_name.'-licence-documents-'.date("d-m-Y-h:i:s").'.zip';
tadman
  • 208,517
  • 23
  • 234
  • 262
luatnd
  • 5
  • 2