加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – 此代码在带有保存文件或openwith的图像查看器中显示图像.

发布时间:2020-12-13 22:31:15 所属栏目:PHP教程 来源:网络整理
导读:?php$img=$_GET['im'];$im="http://localhost/proj1/images/PICS/$img";$contents= file_get_contents("$im");$output_file = 'image.jpg';header("Content-Disposition: attachment; filename=" . $output_file);header("Content-Type: image/jpg");//heade
<?php
$img=$_GET['im'];
$im="http://localhost/proj1/images/PICS/$img";
$contents= file_get_contents("$im");

$output_file = 'image.jpg';
header("Content-Disposition: attachment; filename=" . $output_file);
header("Content-Type: image/jpg");
//header('Content-Length: ' . filesize($contents));
echo $contents;
exit();
?>

解决方法

你没有这个选择.如果指定Content-Disposition:attachment,浏览器将下载该文件.这取决于浏览器的确切程度. Safari或Chrome只会将文件下载到磁盘而不会有任何提示.其他浏览器碰巧问.你无法控制它.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读