我使用readfile();
开始下载并且它工作得很好,但是当尝试使用JavaScript来检查用户是否可以下载文件时,它不会开始下载,而是显示文件的二进制代码。我想要它下载文件。PHP readfile();和JavaScript
我用它来检查,如果用户可以下载该文件:
http.open("GET", "includes/checkdownload.php", true);
在checkdownload.php
我有这个
header('Cache-Control: public');
header('Content-Transfer-Encoding: binary');
header("Content-Type: application/pdf");
header('Content-Disposition: attachment; filename="file.pdf"');
ob_clean();
flush();
readfile("file.pdf");
或'iframe'。 –