[英]PHP file download not working
I have gone through several of the posted topics on PHP file downloads and I'm not finding any solution. 我已经浏览了有关PHP文件下载的多个已发布主题,但没有找到任何解决方案。
When I use MAMP and run the .php file it downloads the file perfectly. 当我使用MAMP并运行.php文件时,它将完美下载该文件。 When I upload it to my server for my web page it downloads the download.php file instead of the pdf I want to allow people to download. 当我将其上传到我的网页服务器时,它将下载download.php文件而不是我希望允许人们下载的pdf文件。
I am not sure what the issue is? 我不确定是什么问题?
Here is my code: download.php 这是我的代码:download.php
<?php
$file_name = "BrianDaubCV.pdf";
$file_url = 'https://s3.amazonaws.com/www.briandaubdesign.com/download.php' . $file_name;
header('Content-Type: application/octet-stream');
header("Content-Transfer-Encoding: Binary");
header("Content-disposition: attachment; filename=\"".$file_name."\"");
readfile($file_url);
?>
resume.html resume.html
<a href="download.php">Download a copy of my resume (PDF)</a>
Check with this. 检查一下。 It is working now. 现在正在工作。 I have added and corrected some lines. 我已经添加并更正了一些行。
$file_name = "BrianDaubCV.pdf";
$file_url = 'https://s3.amazonaws.com/www.briandaubdesign.com/download.php' . $file_name;
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header("Content-Transfer-Encoding: Binary");
header("Content-disposition: attachment; filename=".$file_name);
header('Pragma: public');
readfile($file_url);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.