//移动文件后,重命名文件用。
$basename = $this->getBaseName($name, ".".$type);
//为防止文件名乱码
$basename = iconv("UTF-8","gb2312", $basename);
//移动后的文件名
$saveas = $basename.time().".".$type;
//
组合新文件名再存到指定目录下,格式:存储路径 +
文件名 +
时间 + 扩展名
$this->final_file_path = $this->save_file_path."/".$saveas;
if(!move_uploaded_file($tmpname, $this->final_file_path)) {
$this->last_error = $this->user_post_file['error'][$i];
$this->halt($this->last_error);
continue;
}
//存储当前文件的有关信息,以便其它程序调用。
$this->save_info[] = array("name" => $name, "type" => $type,
"mime_type" => $mime_type,
"size" => $size, "saveas" => $saveas,
"path" => $this->final_file_path);
}
}
return count($this->save_info); //返回上传成功的文件数目
}
/**
* 返回一些有用的信息,以便用于其它地方。
*/
function getSaveInfo() {
return $this->save_info;
}
/**
* 检测用户提交文件大小是否合法
*/
function checkSize($size) {
if ($size > $this->max_file_size) {
return false;
}
else {
return true;
}
}
/**
* 检测用户提交文件类型是否合法