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

yipeiwu_com6年前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控制文件下载速度的方法

本文实例讲述了php控制文件下载速度的方法。分享给大家供大家参考。具体实现方法如下: <?php /* * set here a limit of download...

PHP编程过程中需要了解的this,self,parent的区别

{一}PHP中this,self,parent的区别之一this篇 面向对象编程(OOP,Object Oriented Programming)现已经成为编程人员的一项基本技能。利用O...

PHP字符串中特殊符号的过滤方法介绍

有时候我们会遇到过滤字符串中特殊字符的问题,本文提供了一个处理特殊字符串的方法,可能有遗漏,如果读者发现了可以留言告诉我,谢谢。复制代码 代码如下:function strFilter(...

php使用pecl方式安装扩展操作示例

本文实例讲述了php使用pecl方式安装扩展操作。分享给大家供大家参考,具体如下: 安装pecl cd /usr/local/php/bin/ wget http://pear.ph...

PHP类与对象中的private访问控制的疑问

复制代码 代码如下: class Bar { public function test() { $this->testPrivate(); $this->testPublic...