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

yipeiwu_com5年前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程序设计有所帮助。

相关文章

php中用foreach来操作数组的代码

foreach()有两种用法: 复制代码 代码如下: foreach(array_name as $value) { statement; } 这里的array_name是你要遍历的数...

php发送html格式文本邮件的方法

本文实例讲述了php发送html格式文本邮件的方法。分享给大家供大家参考。具体实现方法如下: <?php $to = "simon@mailexample.com,...

PHP 日,周,月点击排行统计

复制代码 代码如下: $now=time(); //当前时间 $StrUpdate = "Update $tbl_article set hits=hits+1"; if(date("d...

PHP5+UTF8多文件上传类

还有些功能没有加上去,如自动更名,图片处理等.可根据需要自己添加. USE: $up = new upfile(ROOT_PATH.'data/'.date("Ym",time()),a...

php查找字符串出现次数的方法

本文实例讲述了php查找字符串出现次数的方法。分享给大家供大家参考。具体方法如下: 在php中查找字符串出现次数的查找可以通过substr_count()函数来实现,下面就来给大家详细介...