*/
class upfile {
public $fcount = 1; //上传文件的数量
public $ftype = array('jpg','jpeg','gif','png'); //文件格式
public $fsize = 1024; //文件大小单位kb
public $fdir = 'www.111com.net/'; //文件存放目录
public $errormsg = ''; //产生的临时错误信息
/**
*函数名:get_tmp_file($putfile)
*作用:取得上传的临时文件名
*@param array $putfile
*@return string $upimg 返回临时文件名
*/
function get_tmp_file($putfile){
if($this->fcount == 1){
$tmpfile = $putfile['tmp_name'];
}else{
for($i=0;$i<$this->fcount;$i++){
$tmpfile[] = $putfile['tmp_name'][$i];
}
}
return $tmpfile;
}
/**
*函数名:get_suffix($filename)
*作用:取得文件的后缀名
*@param file $filename
*@return string $suffixname 返回后缀名
*/
function get_suffix($filename){
$link = pathinfo($filename);
$suffixname = strtolower($link['extension']);
return $suffixname;
}
/**
*验证文件大小
*@author 赵红健
*@param $filesize
*@return booln
*/
function check_file_size($filesize){
$this->errormsg = '';
if($filesize/1000 > $this->fsize){
$this->errormsg = '警告:文件超出大小!';
return false;
}else{
return true;
}
}
/**
*验证文件类型是否合法
*@author 赵红健
*@param $filesuffix
*@return booln
*/
function check_file_suffix($filesuffix){
$this->errormsg = '';
if(!in_array($filesuffix,$this->ftype)){
$this->errormsg = '警告:文件类型不在允许范围内!';
return false;
}else{
return true;
}
}
/**
*移动临时文件
*@author 赵红健
*@param $filesuffix
*@return booln
*/
function move_temp_file($tmpfile,$targetfile){
$this->errormsg = '';
if(!move_uploaded_file($tmpfile,$targetfile)){
$this->errormsg = '警告:文件移动失败!';
return false;
}else{
return true;
}
}
/**
*函数名:update_file($putfile)
*作用:上传文件
*@param array $putfile
*@return array 文件信息
*/
function update_file($putfile){
$tmpfile = $this->get_tmp_file($putfile);
if(!file_exists($this->fdir)){
$this->errormsg[] = '错误:目录'.$this->fdir.'不存在';
return $this->errormsg;
}
$this->fdir = substr($this->fdir,strlen($this->fdir)-1,1)=='/'?$this->fdir:$this->fdir.'/';
if(!is_array($putfile['size'])){
$fileinfo['file_size'] = $putfile['size'];
if(!$this->check_file_size($fileinfo['file_size'])){
$fileinfo['error'] = $this->errormsg;
return $fileinfo;
}
$fileinfo['file_suffix'] = $this->get_suffix($putfile['name']);
if(!$this->check_file_suffix($fileinfo['file_suffix'])){
$fileinfo['error'] = $this->errormsg;
return $fileinfo;
}
$fileinfo['file_name'] = date('ymdhms').'.'.$fileinfo['file_suffix'];
if(!$this->move_temp_file($tmpfile,$this->fdir.$fileinfo['file_name'])){
$fileinfo['error'] = $this->errormsg;
return $fileinfo;
}
return $fileinfo;
}else{
for($i=0;$i<$this->fcount;$i++){
$fileinfo[$i]['file_size'] = $putfile['size'][$i];
if(!$this->check_file_size($fileinfo[$i]['file_size'])){
$fileinfo[$i]['error'] = $this->errormsg;
continue;
}
$fileinfo[$i]['file_suffix'] = $this->get_suffix($putfile['name'][$i]);
if(!$this->check_file_suffix($fileinfo[$i]['file_suffix'])){
$fileinfo[$i]['error'] = $this->errormsg;
continue;
}
$fileinfo[$i]['file_name'] = date('ymdhms').rand().'.'.$fileinfo[$i]['file_suffix'];
if(!$this->move_temp_file($tmpfile[$i],$this->fdir.$fileinfo[$i]['file_name'])){
$fileinfo[$i]['error'] = $this->errormsg;
continue;
}
}
return $fileinfo;
}
}
}
?>
敢达决战官方正版 安卓版v6.7.9
下载敢达决战 安卓版v6.7.9
下载像素火影骨架佐助 (Perseverance Fire Shadow)手机版v1.16
下载要塞英雄 安卓版v33.20.0-39082670-Android
下载梦想城镇vivo最新版本 安卓版v12.0.1
梦想城镇vivo版是这款卡通风模拟经营类手游的渠道服版本,玩
怦然心动的瞬间 安卓版v1.0
怦然心动的瞬间是一款真人向的恋爱互动游戏,在游戏中玩家将扮演
曼尼汉堡店游戏 安卓版v1.0.3
曼尼汉堡店是一款非常好玩的精品恐怖类型冒险游戏,在这款游戏中
现代总统模拟器去广告版 安卓版v1.0.46
现代总统模拟器是一款休闲养成类游戏,可能对于不少的玩家来说都
现代总统模拟器付费完整版 安卓版v1.0.46
现代总统模拟器高级版在商店是需要付费的,相对于普通版本,高级