php实现改变图片直接打开为下载的方法

前端技术 2023/09/06 PHP

本文实例讲述了php实现改变图片直接打开为下载的方法。分享给大家供大家参考。具体如下:

process.php文件如下:

$file = $_GET[\'file\'];
header(\"Content-type: octet/stream\");
header(\"Content-disposition:attachment;filename=\".$file.\";\");
header(\"Content-Length:\".filesize($file));
readfile($file);
exit;

html文件如下:

<a href=\"process.php?file=pic.jpg\">Image goes Here</a>

希望本文所述对大家的php程序设计有所帮助。

本文地址:https://www.stayed.cn/item/15353

转载请注明出处。

本站部分内容来源于网络,如侵犯到您的权益,请 联系我

我的博客

人生若只如初见,何事秋风悲画扇。