cakephp下载png文件 [英] cakephp download png file
问题描述
我动态生成png文件,点击生成按钮后出现下链接。
I dynamically generate png files which after clicking "generate" button appears "under" link.
"generate button : click" ---> <a href="new_generated.png">DOWNLOAD</a>
点击链接后下载我希望链接的内容(在我的情况下png)开始下载 - 另一个窗口,但下载!
我使用cakePHP。
After clicking link DOWNLOAD I wish content of link(in my case png) start download - no open in another window but download! I am using cakePHP. Can I please for help?
推荐答案
或者,如果您使用Apache Web服务器并启用了mod_headers,您可以使用.htaccess文件强制下载png文件。
Alternatively if you are using Apache web server and have mod_headers enabled you can use an .htaccess file to force download of the png files.
创建一个.htacess文件,并将其放在正在生成/下载png文件的目录中。在该文件中输入:
Create a .htacess file and place it in the directory where your png files are being generated/downloaded from. In that file put this:
<FilesMatch "\.(?i:png)$">
ForceType application/octet-stream
Header set Content-Disposition attachment
</FilesMatch>
这篇关于cakephp下载png文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!