Hi guys,
I use the below code to download an image from a folder on the server.
The image name, size details are stored in database table.
It seems to work ok - (the windows picture viewer opens) but gives a message "No preview available" in the Windows application.
Tried saving the file but get the same.
When the download pop-up window appears it knows the image is a GIF or JPG.
Also opened the image in the folder on the server and it opens fine.
Why won't it open properly when downloaded???
if ($num_results > 0)
{
while($file = mysql_fetch_array($result))
{
// filepath
$uploaddir = '../admin/uploads/images/';
$uploadfile = $uploaddir . basename($file['name']);
echo 'Filename ('.$uploadfile.') '.$file['name'].'....<br />';
}
// Set Headers
if(isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/MSIE/", $_SERVER['HTTP_USER_AGENT']))
{
// IE Bug in download name workaround
ini_set( 'zlib.output_compression','Off' );
}
header('Content-type: ' . $type);
header('Content-length: '. $size);
header("Pragma: public");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header('Content-Disposition: attachment; filename="' . $name . '"');
print($uploadfile);