그래서 내 사이트에 호스팅되어있는 경우 사용자가 버튼을 클릭하여 이미지를 다운로드 할 수 있도록 설정했지만 외부 이미지에는 사용할 수 없습니다. 서버의 폴더에 먼저 복사하지 않고 외부 이미지 (URL 사용)로이 작업을 수행 할 수 있습니까?사용자가 외부 이미지를 다운로드 할 수있게 허용 PHP
이것은 내 사이트의 이미지에 사용하는 것입니다.
$str = $_GET['image'];
$img_name = substr(strrchr($str, '/'), 1);
$image = "../u/i/".$img_name;
if (file_exists($image)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($image));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($image));
ob_clean();
flush();
readfile($image);
exit();
}
도움을 주시면 감사하겠습니다.