archive created by PHP ZipArchive class opened with WinRar but not with WinZip -
i using ziparchive class zip files residing on server. able extract downloaded zip winrar not winzip. , if download created zip directly server via filezilla able extract winzip.
please have @ following script using:-
$zip = new ziparchive(); //create file , throw error if unsuccessful if ($zip->open($archive_file_name, ziparchive::create )!==true) { exit("cannot open <$archive_file_name>\n"); } //add each files of $file_name array archive foreach($file_names $files) { $zip->addfile($file_path.$files,$files); } $zip->close(); //get size of archive $zipped_size = filesize($archive_file_name); //set required headers header("content-description: file transfer"); //header("content-type: application/zip"); header("content-type: application/octet-stream"); header("cache-control: public", false); header("pragma: public"); header("expires: 0"); //header("content-type: application/x-zip-compressed"); //header("content-type: application/force-download");// browsers need header("content-disposition: attachment; filename=cv-archive.zip"); header('expires: 0'); header('cache-control: must-revalidate, post-check=0, pre-check=0'); header("content-transfer-encoding: utf-8"); header('pragma: public'); //header("content-length:". "$zipped_size"); ob_clean(); //ob_clean , flush required make sure no line space generated before output corrupt zip archive flush(); readfile("$archive_file_name"); unlink("$archive_file_name"); // delete temp file (some servers need option) foreach($file_names $files) { unlink($file_path.$files); } exit;
your download script adding additional output, possibly white space before <?php
tag or maybe after ?>
tag in included file. or maybe unlink($file_path.$files);
displaying warning.
Comments
Post a Comment