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下载页面的处理代码的内容,更多相关内容请关注PHP中文网(www.php.cn)!
聚彩手机商城系统,是一款专业于手机销售的独立手机网店系统,他拥有众多的手机参数选项,以及傻瓜式的设置选项,让您可以在5分钟内建立起专业而强大的手机销售网站。他拥有多套模版可以实时切换,前台拥有新闻中心、手机中心、配件中心、软件下载、手机报价、发货查询、保修查询、分店查询、产品的对比功能,代理与加盟的申请等功能,他拥有完善的会员中心,会员等级设置等,集成在线支付接口,超强SEO,可以设置所有页面的t
0
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号