我的站点位于共享服务器上,没有访问php.ini的权限,output buffering设置为no value。
我也尝试过这个.htacces,但没有帮助(也尝试过没有第三行):
1. <IfModule mod_php5.c>
2. php_flag output_buffering On
3. php_value output_buffering 8192
4. php_value output_handler mb_output_handler
5. </IfModule>实际上,我需要它,因为我想在Page中间的标题位置之前调用ob_start(),因为它正在向我发送Header already started error。
提前谢谢。
另外,如果有人可以帮助我完成一个基于javascript的脚本,它可以在页面加载时自动下载一个exe文件(没有任何额外的页面弹出)。
我正在使用的脚本是:
// <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
.
.
.
// Sending Mails and other stuff
if ($mail->send()) {
$alertSuccess = 1;
$alertMsg = "Your license has been sent succesfully.";
## Download Installer
$folder = "license";
$file = "Setupn.msi";
ob_start();
header("Content-disposition: attachment; filename=$file");
header("Content-type: application/octet-stream");
ob_clean();
flush();
readfile("$folder/$file");
}发布于 2015-01-15 11:42:17
我想你想要那个
if ($mail->send()) {
$alertSuccess = 1;
$alertMsg = "Your license has been sent succesfully.";
## Download Installer
$folder = "license";
$file = "Setupn.msi";
ob_clean(); // clear your current output and set headers for your download
// its not possible to remove already setted headers with ob_clean
header("Content-disposition: attachment; filename=$file");
header("Content-type: application/octet-stream");
flush();
readfile("$folder/$file");
exit; // i prefere an exit here, to stop all other scripts
}我先输出一个普通页面,然后通过js将用户重定向到您的下载。
https://stackoverflow.com/questions/27961886
复制相似问题