“Php图像另存为”对话框
我想在单击图像时打开“保存图像”对话框。我设法打开相同的,但当保存时,它不会保存打开保存的图像,因为图像的内容不知何故没有保存 PHP代码:“Php图像另存为”对话框,php,image,http-headers,Php,Image,Http Headers,我想在单击图像时打开“保存图像”对话框。我设法打开相同的,但当保存时,它不会保存打开保存的图像,因为图像的内容不知何故没有保存 PHP代码: $imageName = $_GET['i']; $imageName = $imageName . '-HR.jpg'; header ("Content-Type: application/download"); header ("Content-Disposition: attachment; filename=$imageName"); heade
$imageName = $_GET['i'];
$imageName = $imageName . '-HR.jpg';
header ("Content-Type: application/download");
header ("Content-Disposition: attachment; filename=$imageName");
header("Content-Length: " . filesize("$imageName"));
$fp = fopen("$imageName", "r");
fpassthru($fp);
传递的URL类似于:
mydomain/download_image.php?c=动脉粥样硬化血栓形成&i=颈动脉栓子图示
请提出解决方案。谢谢。也添加此标题
标题(“内容类型:应用程序/强制下载”)代码>也添加此标题
标题(“内容类型:应用程序/强制下载”)代码>我通过使用以下代码成功地做到了这一点:
<?php
$imageName = $_GET['i'];$imageName = $imageName . '-HR.jpg';
$imageCatName = $_GET['c'];
$imageCatName = ucwords($imageCatName);
$file_path = $docRoot . '/static/media/images/content/image_library/'.$imageCatName . '/'. $imageName;
if(file_exists($file_path)) {
header("Content-disposition: attachment; filename={$imageName}");
header('Content-type: application/octet-stream');
readfile($file_path);
}else {
echo "Sorry, the file does not exist!";
}
?>
仍然非常感谢您的支持。:) 我通过使用以下代码成功地做到了这一点:
<?php
$imageName = $_GET['i'];$imageName = $imageName . '-HR.jpg';
$imageCatName = $_GET['c'];
$imageCatName = ucwords($imageCatName);
$file_path = $docRoot . '/static/media/images/content/image_library/'.$imageCatName . '/'. $imageName;
if(file_exists($file_path)) {
header("Content-disposition: attachment; filename={$imageName}");
header('Content-type: application/octet-stream');
readfile($file_path);
}else {
echo "Sorry, the file does not exist!";
}
?>
仍然非常感谢您的支持。:) 有什么保存吗?即使它不是一个有效的图像?如果是的话,那是什么!有什么保存吗?即使它不是一个有效的图像?如果是的话,那是什么!