Forum Moderators: coopster
$zip_file = zip_open($_FILES['filename']['tmp_name']);
while ($zip_entry = zip_read($zip_file))
{
if (preg_match('/jpg$/i', zip_entry_name($zip_entry))>0)
{
echo "File Name: ".zip_entry_name($zip_entry)."<br>";
echo "File Size: ".number_format(zip_entry_filesize($zip_entry))."<br>";
$image_data = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
echo "strlen(imagedata): ".strlen($image_data)."<br>";
echo "Image Data: ".$image_data;
die();
$fhandle = fopen($tmp_directory.zip_entry_name($zip_entry), 'wb');
fwrite($fhandle, $image_data);
fclose($fhandle);
}
}
zip_close($zip_file);
}
PHP4 Output:
File Name: 20060401-0067.jpg
File Size: 66,368
strlen(imagedata): 0
Image Data:
PHP5 Output:
File Name: 20060401-0067.jpg
File Size: 66,368
strlen(imagedata): 66368
Image Data: (jpeg data)
Any thoughts on why it might work on PHP5 and not PHP4?
if you're working with binary data you should always use the mb functions for string functions (like mb_strlen etc).