Rik*_*ood 12 php forms download back-button
我有一个用户在线完成的Web表单.当他们按提交时,它将为他们开始文件下载.
目前,我处理表单提交并为用户生成合适的文件,并使用合适的标题将其关闭.例如...
header('Content-type: "application/octet-stream"');
header('Content-Disposition: attachment; filename="yourfile.txt"');
header("Content-Transfer-Encoding: binary");
Run Code Online (Sandbox Code Playgroud)
但是,由于这会立即开始下载,因此浏览器会将原始表单保留在屏幕上.
下载完成后(或下载开始之前)我真的想去一些"谢谢"屏幕.我知道这是可能的,因为您访问的几乎每个下载站点都会这样做(通常在下载开始之前为您提供完整的广告).
那么,如何显示一个"谢谢"屏幕,在一秒钟后开始下载?
如何提出任何解决方案会影响后退按钮的行为,因为我不希望在没有重新填充表单的情况下再次下载文件?
我在服务器上使用PHP,并且可以依赖客户端上可用的Javascript(和jQuery).
谢谢.
Gum*_*mbo 23
您可以将表单发送到Thank you文档并在文件下载中添加META刷新:
<meta http-equiv="refresh" content="3;url=download.php">
<p>Thank you! The download will start in 3 seconds. If not, use this link to download the <a href="download.php">file</a></p>
Run Code Online (Sandbox Code Playgroud)