简体   繁体   中英

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.

When I use MAMP and run the .php file it downloads the file perfectly. 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.

I am not sure what the issue is?

Here is my code: 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

<a href="download.php">Download a copy of my resume (PDF)</a>

Here is the website

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM