Hey,
Ok basically I want to read from a zip file (which I've done successfully) and then use each of the files within that zip file to resize and move them to a different directory.
Here is the code:
<?
$dh = opendir("/home/www/images");
while (($file = readdir($dh)) !== false)
{
if ($file == '.' or $file == '..') continue;
$zip_path = "/home/www/images/".$file;
$zip_archive = zip_open($zip_path);
$zip_file = zip_read($zip_archive);
do
{
$newFilename = zip_entry_name($zip_file);
$zip_file_open = zip_entry_open($zip_archive, $zip_file, "");
$filetoopen = "/home/www/images/" . $newFilename;
$filepointer = fopen ($filetoopen, "w");
if (is_writable ($filetoopen))
{
for ($row = 0; $row <= zip_entry_filesize($zip_file); $row += 1024)
{
$filename = generate_filename();
$year = date(Y);
#$file = zip_entry_read ($zip_file);
$file = zip_entry_name ($zip_file);
var_dump($file);
#upload_image($file['tmp_name'], $file['type'], 'jpg', 740, 420, "/home/www/images/", $year, $filename, 'full_', 1);
#upload_image($file['tmp_name'], $file['type'], 'jpg', 418, 237, "/home/www/images/", $year, $filename, 'main_', 1);
#upload_image($file['tmp_name'], $file['type'], 'jpg', 134, 77, "/home/www/images/", $year, $filename, 'thumb_', 1);
#fwrite ($filepointer, zip_entry_read ($zip_file));
}
}
fclose ($filepointer);
chmod ($filetoopen, 0777);
zip_entry_close($zip_file);
$zip_file = zip_read($zip_archive);
} while ($zip_file != "");
zip_close($zip_archive);
}
closedir($dh);
?>
Thing is - when I var_dump the $file variable it just returns something like string(6) "03.jpg"
How do I get the 'tmp_name' and 'type' of each file within this zip file and then use it to resize the image?
Any ideas?
Cheers,
Chris