모든 이미지를 저장하는 S3 계정이 있습니다.다운로드 Amazon S3 PHP 스크립트에 저장된 이미지
mysite.s3.amazonaws.com/imagename.JPG
이 URL은 제한된 사용자로 업로드됩니다. 이 비밀 이미지의 다운로드 URL을 만들어야합니다. 이 다운로드 URL은 업로드 된 사용자 만 사용할 수 있습니다.
어떻게 PHP로 이미지 파일을 안전하게 다운로드 할 수있는 코드를 작성할 수 있습니까?
는 URL의 모양을 수 있음 같은 이미지 파일을
<a href="download.php?filename='imagename.JPG'>Download</a>
Download.php
<?php
$filename ="http://mysite.s3.amazonaws.com/" . $_GET["filename"];
$buffer = file_get_contents($filename);
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/octet-stream");
header("Content-Transfer-Encoding: binary");
header("Content-Length: " . strlen($buffer));
header("Content-Disposition: attachment; filename=$filename");
echo $buffer;
?>
귀하의 노력은 어디입니까? 아니면 혼자서하려고하지 않았습니까? –