exit()能輸出錯誤信息,但不能用return
/**
*顯示錯誤?
*/
protected function showError(){
// exit('<span style="color:red">'.$this->error.'</span>');
return $this->error;
}
/**
* 上傳文件
* @return string
*/
public function uploadFile(){
if($this->checkError()&&$this->checkSize()&&$this->checkExt()&&$this->checkMime()&&$this->checkTrueImg()&&$this->checkHTTPPost()){
$this->checkUploadPath();
$this->uniName=$this->getUniName();
$this->destination=$this->uploadPath.'/'.$this->uniName.'.'.$this->ext;
$this->newfile=$this->uniName.'.'.$this->ext;
if(@move_uploaded_file($this->fileInfo['tmp_name'], $this->destination)){
// return ?$this->destination;
return array ($this->uniName.'.'.$this->ext);
}else{
$this->error='文件移動失敗';
$this->showError();
}
}else{
$this->showError();
}
}
2017-03-14
你return完之后要輸出是在你實例化類后輸出的