本文實例講述了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程序設計有所幫助。