php 上传文件出现无法移动的问题

Warning:move_uploaded_file(/propic/1283240615104.jpg)[function.move-uploaded-file]:fa... Warning: move_uploaded_file(/propic/1283240615104.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in /yoyodk/www/includes/upload.php on line 37Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpsg000S' to '/propic/1283240615104.jpg' in /yoyodk/www/includes/upload.php on line 37错误信息。。。下面是我的类代码(上传到其他空间就不出错,这个空间就有问题了)。。。<?phpclass Upload implements IUpload {  public $allowType = array('.jpg','.gif','.png','.txt','.rar','.doc','.exe','.zip','.log');  public $allowSize = 5120000;//500kb  private $file = null;  private $fileExtension = null;  private $fileSize = null;  private $fileName = null;  private $uploadPath = null;  public function __construct( $inputName , $uploadPath ){      $this->file = $_FILES[$inputName];  $this->uploadPath   = $uploadPath;  $this->fileExtension = strtolower(strrchr($this->file[name],"."));  $this->fileSize = $this->file[size];  $this->fileName = $this->getFileName(); }  public function _upload(){  if($this->fileSize > $this->allowSize){   $this->Err("上传的文件过大,上传文件的大小不得超过{$this->allowSize}");  }  if(!in_array( $this->fileExtension , $this->allowType  )){   $this->Err("上传文件类型错误,请上传\"" . implode( "," , $this->allowType) . "\"!" );  }  if(!file_exists( ROOT . "/" . $this->uploadPath )){   $this->createDir(ROOT . "/" . $this->uploadPath);  }      if(!move_uploaded_file( $this->file[tmp_name] , "/" . $this->uploadPath . "/" . $this->fileName )){   //$this->Err("上传失败请重试!" );   exit;  }  return true; } public function getUploadedPath(){  return "/".$this->uploadPath . "/" . $this->fileName; } private function createDir($dir, $mode = 0777){  if (is_dir($dir) || @mkdir($dir,$mode)) return TRUE;  if (!$this->createDir(dirname($dir),$mode)) return FALSE;//用递归创建多层目录  return @mkdir($dir,$mode); } private function getFileName(){  return  time() . rand(100,900) . $this->fileExtension; } private function Err($msg){  global $js;  $js->Alert($msg);  $js->Back(); }}?> 展开
 我来答
百度网友85409ee
2012-02-25 · TA获得超过131个赞
知道答主
回答量:78
采纳率:0%
帮助的人:41.8万
展开全部
从你的代码来看,这段有错
move_uploaded_file( $this->file[tmp_name] , "/" . $this->uploadPath . "/" . $this->fileName )

正确的代码应该为(加一个ROOT路径)
move_uploaded_file( $this->file[tmp_name] ,ROOT. "/" . $this->uploadPath . "/" . $this->fileName )
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式