English 中文(简体)
图像文件下载问题
原标题:Image file download problem
  • 时间:2009-10-09 13:36:43
  •  标签:

我在从服务器下载任何图像档案方面遇到问题。

我能够成功地卸下这些弹药,并且能够从它们卸载和储存的地点打开。

当使用我的职能下载图像文件时,文件尺寸也正确,但一旦打开,就会发现错误。 !

$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(!$fdl=@fopen($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);
    }

我正在利用国际电子计算机作为浏览器。

我正在使用这一密码,下载档案,而不是在浏览器上显示。 该书执行,并促使我是否希望公开/拯救档案。 如果是拯救档案,那么规模也正确,但图像确实没有显示。 当我正确地点击并看到档案摘要时,它说没有摘要。

提前感谢。 愿提供帮助。

问题回答

从你的法典中看不出,你是否利用这种PHP的刀子在网页上为图像服务,例如:

<img src="my-php-script.php" alt="blah blah blah" />

如果是,你的内容类型是不正确的。 你们需要使用图像的监理系统类型,如图像/影像、图像/笔像、图像/笔记或图像/手法,两者都是最适当的。

这一行文:header("Content-type: application/octet-stream”);在我看来是鱼的。 您不妨尝试给予实际奇迹,看看这是否有助于

问题在于监测和评价。 请在此回顾:

http://www.daniweb.com/forums/thread122055.html

如果你想看到浏览器中的图像的话。

如果你想要把他们作为双筒下载,那么就离开了我们的奇迹。

另外,请将文件公开格式从“r”改为“rb”。





相关问题
热门标签