public function down_image(){
//header('Content-type: application/json');
// 图片文件路径
$param_data = $this->request->param('','','trim,strip_tags');
if (empty($param_data['image_path'])){
$this->error(__("image_path is not empty"));
}
// $filePath = 'path/to/your/image.jpg'; // 图片文件路径
$fileName = 'image.jpg'; // 下载时显示的文件名
$filePath = $param_data['image_path'];
// 设置响应头告诉浏览器这是一个要下载的文件
header("Cache-Control: public");
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . $fileName . '"');
header("Content-Transfer-Encoding: binary"); //告诉浏览器,这是二进制文件
header('Expires: 0');
header('Pragma: public');
// 确保文件可读取
readfile($filePath);
}
Safari浏览器下载图片提示html解决方案
最新推荐文章于 2024-08-09 08:31:19 发布