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
精彩评论