2012-03-26 161 views
0

我想強制圖像的下載。我發現這個代碼:強制下載圖像

<FilesMatch "\.(?i:jpg|gif|png)$"> 
    Header set Content-Disposition attachment 
</FilesMatch> 

但我有一個特殊的要求。我的圖片有像.png

<a target="_blank" id="save_to_pc" href="/image.php?width=720&amp;height=480&amp;file=files/galleries/1549/01a750273f66cd8637bcd2811a34a3e5.jpg&amp;nocrop=1"></a> 

延伸有人可以幫我過濾掉該圖像,讓用戶下載呢?

+0

的可能重複[強制文件(圖像)的.htaccess下載](http://stackoverflow.com/questions/4218466/force-fileimage-download-with-htaccess) – 2012-03-26 12:12:35

+0

@tereško是絕對沒有 – 2012-03-26 12:24:01

+0

@ Fincha:時間學習什麼頭,以及如何在Apache的*或* PHP工作。 – hakre 2012-03-27 10:29:01

回答

2

您可以通過在image.php的報頭信息提供Content-Disposition做到這一點。

header('Content-Disposition: attachment; filename="<your image filename>"'); 
+0

謝謝!將在6分鐘內接受你的答案 – 2012-03-26 12:17:07