PHP 图像另存为对话框
我想在单击图像时打开保存图像对话框。我设法打开相同的图像,但保存时,它不会保存打开的已保存图像,因为图像的内容未以某种方式保存。
PHP 代码:
$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=atherothrombosis&i=embolus-carotid-artery-illustration
请建议解决方案。谢谢。
I wanted to open a save image dialog box when I click on an image. I managed to open the same but when saved, it does not save open saved image as the content of image is not saved somehow.
PHP code:
$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);
The passing URL is something like:
mydomain/download_image.php?c=atherothrombosis&i=embolus-carotid-artery-illustration
Please suggest solution. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
还添加此标头
header("Content-Type: application/force-download");
add this header also
header("Content-Type: application/force-download");
我设法使用下面的代码来做到这一点:
仍然非常感谢您的支持。 :)
I managed to do so by using below code:
still thanks a lot for your support. :)