When creating an image download site, users often need to download images, but the image browser can open them directly. what should I do? Is there any way to download an image file in the pop-up download box? phperz.com certainly does, the php header function can provide this method. You can copy the following code from the php programmer's house.
When creating an image download site, users often need to download images, but the image browser can open them directly. what should I do? Is there any way to download an image file in the pop-up download box? phperz.com certainly does, the php header function can provide this method. You can copy the following code from the php programmer's house.
In progressImageDownloadWhen the site, you often needDownloadImage,ImageThe browser can be opened directly. What should I do?MethodAllowsImageType file pop-upDownloadBoxDownloadPhperz.com
Of course, some php header functions can provide suchMethodPhp programmer's house
You can copy the following code to test www.phperz.com.
Reference content is as follows: $ Filename = "123.jpg ";//ImageAddress, either absolute or relative. Header ("Content-Type: application/force-download "); Header ('content-Disposition: attachment; filename = "'. $ filename .'"'); $ Img = file_get_contents ($ filename ); Echo $ img; ?> |
Www.phperz.com
The effect is as follows: www.phperz.com
Www.phperz.com
The key point is the php programmer's house.
Header ("Content-Type: application/force-download ");
Header ('content-Disposition: attachment; filename = "'. $ filename .'"');
Phperz ~ Com
These two lines of code allow the browser to be forcedDownloadFile
Phpzer