在我的web应用程序上,我希望用户下载页面上的一些信息,然后重定向。
<?php
header('Content-Description: File Transfer');
header('Content-Type: text/force-donwload');
header('Content-disposition: attachment; filename=Your_Fibble_Password.txt');
header('Content-Length: '.strlen($password));
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Expires: 0');
header('Pragma: public');
echo $password;
header('location:./');
?>
因此,location头在这里起作用,页面被重定向
但是上面的文件传输头不起作用。
注意:我不能使用exit,因为我在它下面执行了一些代码。
发布于 2018-06-14 05:36:01
据我所知,这是不可能的。技术上的限制是:“你不能在内容之后发送头部”,所以,在这种情况下,你发送密码下载( txt格式的文件),然后你尝试发送更多的头部来指示重定向。也许你可以在前端应用程序中模拟这种行为,在javascript中执行document.location。
https://stackoverflow.com/questions/50846416
复制相似问题