本文主要是介绍Safari浏览器下载图片提示html解决方案,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
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解决方案的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!