开发者

how do i make users to download jpg files

i need to make users download jpg files. i know that if i send them the link to the jpg file, the browser will just display the jpg file. Then the user must do rightclick -> s开发者_JS百科ave picture as

However, i want to force the download dialog box to appear so that they can download the jpg file. Anyone can help me with that?


You need to set the correct headers in your PHP script that serves the image to the user

header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=$file");
header("Content-Type: image/jpg");
header("Content-Transfer-Encoding: binary");

//read image, write to user
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜