这是一种非常粗略的方式,您可以代理图像并提示下载。
<?php
$url = "http://www.branded3.com/wp-content/uploads/2011/05/Google_Chrome1.jpg";
//Get file
$source = file_get_contents($url);
//Image Mime types
$images = array('jpg'=>'image/jpg','png'=>'image/png','png'=>'image/png');
//Is it an image extention
if(in_array(substr($url,-3),$images)){
$type = $images[substr($url,-3)];
}else{
//No its somthing else
$type = 'application/octet-stream';
}
//Set the headers
header('Content-Description: File Transfer');
header('Content-Type: '.$type);
header('Content-Disposition: attachment; filename='.basename($url));
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . sprintf("%u", strlen($source)));
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Expires: 0');
header('Pragma: public');
//echo the source
echo $source;
?>