您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

PHP文件上载页简单实现

2024/10/17 7:24:16发布26次查看
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://www.lpfrx.com/wp-content/themes/prosense/images/rss-feed-icon.jpg);
搭配jquery前后台一起处理还是很给力的,例如图片
$(img).click(function(){
var path = $(this).attr(src);
location.href=test.php?path=+path;
})
测试过了
无论下载什么格式,改一下就行了,特此备份,以便查阅
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product