“另存为”对话框显示并允许用户下载图片,但下载的图片已损坏且可以查看。
<?php
$username = $_GET['username'];
$size = $_GET['size'];
$ext = $_GET['ext'];
$border = $_GET['border'];
$basename = basename($_SERVER['REQUEST_URI']);
if(!isset($size)) { $size = 'small'; }
if(!isset($ext)) { $ext = 'jpeg'; }
if(!isset($border)) { $border = 'true'; }
$file = 'avatar-'.$size.'-'.$username.'.'.$ext;
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.$basename);
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
#header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
exit;
?>
下载链接:download picture。应该下载的图片:avatar-Luxie.jpeg
顺便说一句,图片是由另一个脚本生成的,我不知道是否重要,如果你需要它我可以发布代码。
.htaccess文件的一个片段:
Rewriterule ^images/user-([A-Za-z0-9_-]{1,10}).jpeg$ /system/avatar-dl.php?username=$1&size=big&ext=jpeg&border=true [L,QSA]
答案 0 :(得分:0)
这是文件的内容:
Warning: readfile(avatar-big-Luxie.png): failed to open stream: No such file or directory in /home/u720533143/public_html/system/avatar-dl.php on line 24
在我看来文件就不存在了。