[英]Images downloaded as .part file
i want to allow user to download some png image in my HTML page. 我想允许用户在我的HTML页面中下载一些png图像。
i searched and i found this : 我搜索后发现:
window.location.href = img.src.replace('image/png', 'image/octet-stream');
it's works fine (open a dialog to save the image file ). 正常(打开一个对话框来保存图像文件)。
but the problem that the file name looks like : <random letters>.part
. 但是文件名看起来像这样的问题:
<random letters>.part
。
so how to solve this ? 那么如何解决呢?
and can i change my own file name ? 我可以更改自己的文件名吗?
thanks in advance. 提前致谢。
EDIT : 编辑:
i want it in the browser side not server side (using java script). 我希望它在浏览器端而不是服务器端(使用Java脚本)。
您需要在标题中设置内容配置,以强制下载文件名。
header('Content-Disposition: attachment; filename="download.png"');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.