这是我的php脚本,它执行下载:
$link = 'www.example.com';
$url = urlencode($link);
$image = "http://chart.googleapis.com/chart?chs=75x75&cht=qr&chl=$url&choe=UTF-8&chld=L|0";
$filename = file_get_contents("$image");
header("Pragma: public");
header("Expires: 0"); // set expiration time
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Disposition: attachment; filename='qr code';");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($filename));
echo $filename;
这下载了一个文件,但它只在绘画中打开,而不是在photoshop中打开。作为提示,似乎没有与文件相关联的文件类型(例如png或jpg)。
我需要上面的所有标题,所以这在所有浏览器中都可以使用。
谢谢。
也许可以在文件名头中传递文件扩展名。
header("内容处置:附件;filename='qr_code.jpg';");