php 文件上传类(9)
来源:未知 责任编辑:责任编辑 发表时间:2015-10-08 14:15 点击:次
}
private function proRandName(){
$tmpStr= "abcdefghijklmnopqrstuvwxyz0123456789";
$str="";
for ($i=0;$i<8;$i++){
$num=rand(0,strlen($tmpStr));
$str.=$tmpStr[$num];
}
return $str;
}
private function makePath(){
if(!@mkdir($this->filePath,0755)){
$this->setOption('errorNum',-7);
}
}
private function copyFile(){
$filePath=$this->filePath;
if($filePath[strlen($filePath)-1]!='/'){
$filePath.='/';
}
$filePath.=$this->newFileName;
if(!@move_uploaded_file($this->tmpFileName,$filePath)){
$this->setOption('errorNum',-5);
}
return $this->errorNum;
}
function getNewFileName(){
return $this->newFileName;
}
private function getFileErrorFromFILES(){
return $this->fileField['error'];
}
private function getFileTypeFromFILES(){
$str=$this->fileField['name'];
$aryStr=split("\.",$str); //将字符串分割到数组中
$ret=strtolower($aryStr[count($aryStr)-1]);
return $ret;
}
private function getFileNameFromFILES(){
return $this->fileField['name'];
}
private function getTmpFileNameFromFILES(){
return $this->fileField['tmp_name'];
}
private function getFileSizeFromFILES(){
return $this->fileField['size'];
}
public function getErrorMsg(){
$str="上传文件出错:";
switch ($this->errorNum){
case -1:
$str.="未知错误!";
break;
case -2:
$str.="未允许类型!";
break;
case -3:
$str.="文件过大!";
break;
case -4:
$str.="产生文件名出错!";
break;
case -5:
$str.="上传失败!";
break;
case -6:
$str.="目录不存在!";
相关新闻>>
- 发表评论
-
- 最新评论 更多>>