我面临从服务器下载任何图像文件的问题。图像文件下载问题
我可以成功上传它们,并可以从上传和存储位置打开它们。
当我使用我的功能下载图像文件完全下载,文件大小也是正确的,但是当我打开它们时出现错误无图像预览!!!
$fileString=$fileDir.'/'.$fileName; // combine the path and file
// translate file name properly for Internet Explorer.
if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE"))
{
$instance_name = preg_replace('/\./', '%2e', $instance_name, substr_count($instance_name, '.') - 1);
}
// make sure the file exists before sending headers
if([email protected]($fileString,'r'))
{
die("Cannot Open File!");
}
else
{
header("Cache-Control: ");// leave blank to avoid IE errors
header("Pragma: ");// leave blank to avoid IE errors
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"".$instance_name."\"");
header("Content-length:".(string)(filesize($fileString)));
sleep(1);
fpassthru($fdl);
}
我使用IE作为浏览器。
我正在使用此代码片段来下载文件,而不是在浏览器上显示。该脚本执行并提示我是否打开/保存该文件。当我保存文件的大小也是正确的,但图像不显示。当我右键单击并查看文件摘要时,说明摘要不可用。
在此先感谢。请帮助。
尝试从“@fopen”删除@看看错误,如果任何 – 2009-10-09 13:39:07