I have a zip file "test.zip" which contain many files and a picture called "dp.bmp". So i use below script to search and show that picture file. But unfortunately, the pic could'nt display correctly.
The image only show horizontal line of picture (not showing whole picture as it's height and width), like below pic :
Then i tried to modify the line :
echo '<img width="700" height="700" src="data:image/bmp;base64,'.base64_encode($contents).'"/>';
But still only show horizontal line of that picture
Here is my original source code :
<?php
$zip = zip_open("test.zip");
if ($zip)
{
while ($zip_entry = zip_read($zip))
{
if (zip_entry_open($zip, $zip_entry))
{
$expFile = explode("/",zip_entry_name($zip_entry));
if ($expFile[1] == "dp.bmp" ) {
$contents = zip_entry_read($zip_entry);
echo '<img src="data:image/bmp;base64,'.base64_encode($contents).'" />';
zip_entry_close($zip_entry);
}
}
}
zip_close($zip);
}
?>
I also test with other picture file and format such as JPG, but still couldn't show whole pic.
Any solution would be appreciated. Thanks!