简体   繁体   中英

Amazon S3/Cloadfont force download zip file

After having generated a expiring amazon CloudFont link by using this script http://aws.amazon.com/code/3514?_encoding=UTF8&jiveRedirect=1/ ).

I would like to force the download to start by using php. Al tough I thought this would be easy it seem rather complicated. And http://docs.amazonwebservices.com/AWSSDKforPHP/latest/#i=AmazonS3 doesn't seem to get me really further.
All file are .zip files.

I hope someone here could help me further.

The code I've got so far seems far from right:

$url = $_POST['url'];

header('Content-Disposition: attachment; filename='.basename($url));
header('Content-Type: application/zip');
readfile($file);

here's some headers i had to use in the past to get force download to work properly in various browser over https, perhaps it'll help you too:

header("Pragma: public");
header("Expires: 0");
header("Content-Transfer-Encoding: binary");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);

then add your previous code lines.

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