I’m using PHP to generate and force download a ZIP file that contains a sequence of photos listed from a database table.
Everything seems to be working great, but I can’t seem to figure out why the photos keep downloading at the same file size.
I’m assuming the files arn’t being compressed correctly, I thought it might be the headers but I’m just not sure.
Could anybody shed some light on my problem?
CODE:
require ("zipfile.inc.php");
$zipfile = new zipfile();
$filedata = implode("", file("zipfile.inc.php"));
$getspdi = mysql_query("SELECT * FROM `wedding_photos` WHERE `user_hash` = '$logged[ip]' ORDER BY `id` DESC LIMIT 0, 1000") or die(mysql_error());
$getspd = mysql_fetch_array($getspdi);
while ($photos = mysql_fetch_array($getspdi)) {
$zipfile->add_file($filedata, "$photos[img]");
}
header("Content-Type: application/zip");
header("Content-Transfer-Encoding: binary");
header("Content-disposition: attachment; filename=szipfile.zip");
echo $zipfile->file();
I’m using an exsisting class called “zipfile.inc.php” (http://www.devco.net/code/zipfile.inc.txt).
Any help would be appreciated,
Thanks.
This line makes no sense:
With that, you are adding the contents of
zipfile.inc.phpand giving it the image’s name.You need to fetch the actual image data from somewhere.