当单击 jquery noty 中的按钮时,我正在尝试使用 PHP 启动下载。当通知应该出现并且萤火虫控制台中没有错误时,我得到了空白页。
var noty_id = noty({
text: 'blah',
type: 'success',
buttons: [
{addClass: 'btn btn-primary', text: 'Download', onClick: function($noty) {
$noty.close();
<?php
if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
exit;
}
?>
}}
]
});