首页 > PHP > 通过PHP下载图片文件

通过PHP下载图片文件

2009年4月8日

通过PHP下载图片文件, 不需要使用右键另存为等这样的操作, 直接下载.

$img = substr($row['bqpath'], strrpos($row['bqpath'], '/')+1);
$ext = substr($row['bqpath'], strrpos($row['bqpath'], '.')+1);
header('Content-Type: image/'.$ext); 
header("Content-Disposition:attachment;filename=".$img);
header('Content-Transfer-Encoding: binary');
readfile(WEB_PATH.$row['bqpath']);

其他文件的下载同理…

admin PHP

  1. 2009年4月8日18:43 | #1

    贵站这是个我这种菜鸟学习的好地方啊~
    想和贵搏友链~不知口否

    万维网事:www.wanvee.info

  2. 2009年4月9日00:32 | #2

    欢迎首页互连.

  3. 2009年4月9日08:00 | #3

    @flywolf
    博主真是神速啊!
    谢谢了,贵站首页链接已添加!

  4. 2009年10月11日18:26 | #4

    博客做的不错吗

  1. 本文目前尚无任何 trackbacks 和 pingbacks.