[英]PHP force download of Amazon S3 link
我有以下代碼
header("Content-Description: File Transfer");
header('Content-Type: audio/mp3');
header("Content-Disposition: attachment; filename=" . $arrResults['audioLink'] . ".mp3");
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header("Content-Transfer-Encoding: binary");
$strLink = 'http://ag-org.s3.amazonaws.com/members/tele_classes/' . $arrResults['audioLink'];
ob_clean();
flush();
readfile($strLink);
但是,當單擊執行此代碼的下載鏈接時,它總是返回一個 0 字節的文件。 存儲桶中的所有文件都設置為公開。
我在這里做錯了什么?
.mp3
擴展名真的不是文件名的一部分,因為它存儲在 S3 上嗎?
您將.mp3
附加到 Content-Disposition header 中的文件名,但不是 URL 傳遞給readfile
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.