您好,欢迎访问一九零五行业门户网

PHP下载页面的处理代码

php下载页面的处理代码
function get_extension($file){ return substr(strrchr($file, '.'), 1); } function get_name($path){ return substr(strrchr($path, '/'), 1); } function getimage($url,$filename="") { $fbufsize = 8096; $ext = get_extension($url); $filename = get_name($url); $type = array( 'gif' => 'image/gif', 'jpeg' => 'image/jpeg', 'jpg' => 'image/jpeg', 'jpe' => 'image/jpeg', 'png' => 'image/png', ); $imgtype = isset($type[$ext])?$type[$ext]:die("类型不符"); header('content-description: file transfer'); header('expires: 0'); header('cache-control: must-revalidate, post-check=0, pre-check=0'); header('pragma: public'); header("content-type: ".$imgtype); header("content-transfer-encoding: binary"); header('content-disposition: attachment; filename="'.$filename.'"'); header("content-length:" . getimagesize($url)."\n\n" ); $fp = fopen($url,"r"); while(!feof($fp)) { print(fread($fp,$fbufsize)); flush(); ob_flush(); } fclose($fp); exit; } getimage("http://snowcoal.com/images_6930/201407/1405910422162.jpg");
以上就是php下载页面的处理代码的内容。
其它类似信息

推荐信息