簡體   English   中英

PHP文件下載不起作用

[英]PHP file download not working

我已經瀏覽了有關PHP文件下載的多個已發布主題,但沒有找到任何解決方案。

當我使用MAMP並運行.php文件時,它將完美下載該文件。 當我將其上傳到我的網頁服務器時,它將下載download.php文件而不是我希望允許人們下載的pdf文件。

我不確定是什么問題?

這是我的代碼: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>

這是網站

檢查一下。 現在正在工作。 我已經添加並更正了一些行。

$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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM