Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/275.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP强制下载AmazonS3链接_Php_Amazon S3_Download - Fatal编程技术网

PHP强制下载AmazonS3链接

PHP强制下载AmazonS3链接,php,amazon-s3,download,Php,Amazon S3,Download,我有以下代码 header("Content-Description: File Transfer"); header('Content-Type: audio/mp3'); header("Content-Disposition: attachment; filename=" . $arrResults['audioLink'] . ".mp3"); header('Expires: 0'); header('Ca

我有以下代码

        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字节的文件。所有文件在bucket中都设置为public


我做错了什么?

扩展名是否真的不是文件名的一部分,因为它存储在S3上


您正在将
.mp3
附加到内容处置头中的文件名,而不是要传递到
readfile

的URL。您是否启用了fopen包装器?噢,我讨厌这样做