Rob
Rob

Reputation: 11

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);

Upvotes: 1

Views: 589

Answers (1)

malko
malko

Reputation: 2382

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.

Upvotes: 1

Related Questions