[英]Set Content-Type dynamically
I have the following code, which i'm using to force download of files rather than opening in browser. 我有以下代码,我用来强制下载文件而不是在浏览器中打开。
if(isset($_POST['file_name'])){
$player_file = $_POST['file_name'];
$accessKey = "REMOVED";
$secretKey = "REMOVED";
$bucket = $_POST['bucket'];
$fname = $_POST['fname'];
$zip_url = el_s3_getTemporaryZipLink($accessKey, $secretKey, $bucket, $fname);
$mp3_url = el_s3_getTemporaryMP3Link($accessKey, $secretKey, $bucket, $fname);
header('Content-type: audio/mpeg3');
header('Content-Disposition: attachment; filename="themixtapesite_'.$player_file.'"');
readfile($mp3_url);
exit();
}
As you can see, i pass all the variables from a form. 如您所见,我传递了表单中的所有变量。 Then use that information to generate a unique Signed URL for the file stored on Amazon S3. 然后使用该信息为存储在Amazon S3上的文件生成唯一的签名URL。
If the file is an MP3 i need it to use the $mp3_url and if it's a Zip file i need to use the $zip_url. 如果文件是MP3,我需要它使用$ mp3_url,如果它是Zip文件,我需要使用$ zip_url。
This has to be really simple, but i've been sat in front of this screen all day now i've got a complete mind blank! 这一定非常简单,但是我整天坐在这个屏幕前,现在我已经有了一个完整的空白!
Any help appreciated. 任何帮助赞赏。
$url
- just one variable storing the extension, not two different variables. 切换后你应该有$url
- 只有一个存储扩展名的变量,而不是两个不同的变量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.