夏期劇*_*期劇場 8 html download hyperlink
目的是backup.sql
在运行sql dumping脚本(从PHP)后下载转储的文件.通常,转储的.sql
文件在服务器上输出(写入).然后当我对该文件进行href链接时,文件<a href="backup.sql">Download File</a>
在点击时在浏览器内打开,而不是下载.
怎么做?
Gok*_*N K 20
或者您可以download
在html的锚标记中使用新的HTML5属性.
代码看起来像
<a download href="path/to/the/download/file"> Clicking on this link will force download the file</a>
Run Code Online (Sandbox Code Playgroud)
它适用于firefox和chrome最新版本.我应该提一下我没有在IE中查看它吗?:P
将以下行添加到您的.htaccess
文件中。
<Files "backup.sql">
ForceType applicaton/octet-stream
Header set Content-Disposition attachment
</Files>
Run Code Online (Sandbox Code Playgroud)