PHP Classes

Zip file creates and fills with empty files

Recommend this page to a friend!

      Zip  >  All threads  >  Zip file creates and fills with...  >  (Un) Subscribe thread alerts  
Subject:Zip file creates and fills with...
Summary:Zip file creates and fills with empty files
Messages:3
Author:Max
Date:2014-10-10 14:07:08
 

  1. Zip file creates and fills with...   Reply   Report abuse  
Picture of Max Max - 2014-10-10 14:07:08
Hello,

I am using your zip library to add certain pictures to a zip file, and I have the filepaths of the images in an array.

My zip file gets created and fills up, but it only fills up with empty data. Every picture is just 22kb's. I am sure that the filepath is correct, as I printed the images to the screen with that particular filepath.

Here is a link to the script part:
pastebin.com/RZCeZSjE

Here is a quick filepath:

-admin
--modules
---classes
----zip
-----Zip.php

-upload
--98
---image.jpg


If you could explain to me what I'm doing wrong, I would really appreciate it!

Thanks,
Max

  2. Re: Zip file creates and fills with...   Reply   Report abuse  
Picture of Max Max - 2014-10-10 14:20:53 - In reply to message 1 from Max
Well, I have found what I did wrong.

I forgot to use file_get_contents on my addFile.

So the wrong version:
$zip->addFile($zfv, $path);

Turned into the right version:
$zip->addFile(file_get_contents($zfv), $path);

Regards,
Max

  3. Re: Zip file creates and fills with...   Reply   Report abuse  
Picture of dang thi ngoc dang thi ngoc - 2014-11-12 10:25:33 - In reply to message 1 from Max
i would like to add many kind of Files.
how can i add .doc, .png ... file into .zip by function $zip->addFile() ?
Thanks