Downloaded latest php_zip.dll; fixed!
KMiller wrote:
>
> Been playing with this for a few hours and it seems that anything but a
> plain text file (doc,xls,pdf,etc.) is being trashed by ZipArchive.
>
> Has anyone had similar experiences or am I just doing something stupid and
> can't see it?
>
> Whatever the problem is, it certainly is silent about it. I thought it
> may be a permissions thing but that doesn't seem to be it. The one file
> it doesn't mess up is a plain text file. Anything else gets trashed.
>
> -km
>
> public function zipAction() {
> $params = SiteControllers::getParams();
> if(!isset($params['file'])) {
> echo "zip: file param expected - not found";
> return false;
> }
> $file = $params['file'];
> if(!file_exists("uploads/{$file}")) {
> echo "file to zip: {$file} not found";
> return false;
> }
> $zip = new ZipArchive;
> $res = $zip->open("uploads/{$file}.zip", ZipArchive::OVERWRITE);
> if ($res === TRUE) {
> $zip->addFile("uploads/{$file}","{$file}");
> $zip->close();
> unlink("uploads/{$file}");
> echo "{$file} - was zipped";
> return true;
> } else {
> echo "{$file} - zip failed";
> return false;
> }
> }
>
> public function unzipAction() {
> $params = SiteControllers::getParams();
> $file = $params['file'];
> if(!isset($params['file'])) {
> echo "unzip: file param expected - not found";
> return false;
> }
> $zfn = "uploads/{$file}.zip";
> if(!file_exists($zfn)) {
> echo "zip file: {$zfn} not found";
> return false;
> }
> if(file_exists("uploads/{$file}")) {
> echo "file to unzip: {$file} exists";
> return false;
> }
> $zip = new ZipArchive;
> $res = $zip->open($zfn);
> if ($res === TRUE) {
> $zip->extractTo("uploads/");
> $zip->close();
> echo "{$file}: unzipped";
> unlink($zfn);
> return true;
> } else {
> echo "unzip for: {$file} failed";
> return false;
> }
> }
>
>
--
View this message in context:
http://www.nabble.com/zipArchive---corrupting-files--tf3359654.html#a9360328
Sent from the PHP - General mailing list archive at Nabble.com.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php