I am using PCLZIP to create a ZIP that contains few documents and pdfs. On some machine, users are claiming zip to be corrupted.
On my machines, I don't see ZIP to be corrupted, but whenever I try to send that zip via Gmail, it blocks the ZIP saying it contains an executable, but in fact all that zip have are documents and PDF files. So I see relation between people claiming that zip are corrupted and Gmail blocking these zip created from our app.
I have tried extracting all the files and again adding them in a zip using Window's add to archive option. And if I send this zip, gmail doesn't block.
So I believe there has to be some problem when I am creating ZIP in my PHP app.
Here is the relevant portion of the code where I am creating ZIP:
<?php
$archive = new PclZip("exportZIPs/{$randomFileName}.zip");
$orgFile = $document->sAbsStoragePath.$document->sSysFileName;
$filePath = array();
$filePath[] = array( PCLZIP_ATT_FILE_NAME => $orgFile,
PCLZIP_ATT_FILE_NEW_FULL_NAME => "{$someNewName}"
);
foreach ($aList as $key => $value) {
$filePathTmp = "{$SomePath}.pdf";
if(!file_exists($filePathTmp)) {
continue;
}
//$filePath[] = "{$SomePath}.pdf";
$filePath[] = array( PCLZIP_ATT_FILE_NAME => $filePathTmp,
PCLZIP_ATT_FILE_NEW_FULL_NAME => "PDFs/Version-{$sVersion}.pdf"
);
}
$v_list = $archive->add($filePath, PCLZIP_OPT_REMOVE_PATH, 'PDFs');
if ($v_list == 0) {
die("Cannot Create Archive! Try again or contact administrator");
die("Error : ".$archive->errorInfo(true));
}
header("Content-Type: application/zip");
header("Content-Disposition:attachment;filename=\"{$SOMENAME}.zip\"");
readfile("exportZIPs/{$randomFileName}.zip");
@unlink("exportZIPs/{$randomFileName}.zip");
?>
What am I doing wrong?