php 文件上传类(8)
来源:未知 责任编辑:责任编辑 发表时间:2015-10-08 14:15 点击:次
foreach ($options as $key=>$val){
if(!in_array($key,array('filePath','fileField','originName','allowType','maxSize','isUserDefName','userDefName','isRandName','randName')))
continue;
$this->setOption($key,$val);
}
}
private function setFiles(){
if($this->getFileErrorFromFILES!=0){
$this->setOptions('errorNum',-1);
return $this->errorNum;
}
$this->setOption('originName',$this->getFileNameFromFILES());
$this->setOption('tmpFileName',$this->getTmpFileNameFromFILES());
$this->setOption('fileType',$this->getFileTypeFromFILES());
$this->setOption('fileSize',$this->getFileSizeFromFILES());
}
private function setOption($key,$val){
$this->$key=$val;
}
private function setNewFileName(){
if($this->isRandName==false&&$this->isUserDefName==false){
$this->setOption('newFileName',$this->originName);
}elseif ($this->isRandName==true&&$this->isUserDefName=false){
$this->setOption('newFileName',$this->proRandName().'.'.$this->fileType);
}elseif ($this->isRandName==false&&$this->isUserDefName=true){
$this->setOption('newFileName',$this->userDefName);
}else {
$this->setOption('errorNum',-4);
}
}
private function checkValid(){
$this->checkFileSize();
$this->checkFileType();
}
private function checkFileType(){
if(!in_array($this->fileType,$this->allowType)){
$this->setOption('errorNum',-2);
}else {
return $this->errorNum;
}
}
private function checkFileSize(){
if($this->fileSize>$this->maxSize){
$this->setOption('errorNum',-3);
}else {
return $this->errorNum;
}
}
private function checkFilePath(){
if(!file_exists($this->filePath)){
if($this->isCoverModer){
$this->makePath();
}else {
$this->setOption('errorNum',-6);
}
}
相关新闻>>
- 发表评论
-
- 最新评论 更多>>