我在move_uploaded_file后使用rename,返回提示说找不到文件,我又用chmod,file—exist都说找不到,但是上传的文件在目录里啊,而且我用rename做同一个目录里之前上传的文件就好使,怎么回事啊,这个问题已经搞了好几天了,受不了啦!!!!

解决方案 »

  1.   

    相对路径,绝对路径都试过了。
    is_dir能过
    chmod不过
    file_exists不过
    但是要用上次上传的文件就能过,本次的就不过。
    我用的是cPanel系统,在本地的xampp就没问题
      

  2.   

    很正常,因为 move_uploaded_file 的文件的管理权还未交到操作系统
    你 sleep(1) 甚至 usleep(10000) 后就可以 rename 了就是不知道你为什么不一次到位呢?
      

  3.   

    我还真用了sleep,从sleep(1)到sleep(60),还是不行。
    因为我用了ajax的动态上传,用户有可能上传多次,但最后确定只上传一个文件,之前上传的都是废的,所以只把最后那个转移到真正存储的目录,这个tmp的目录定期清就行了。
      

  4.   

    $content = $_GET['storyContent'];
    $author = $_GET['storyAuthor'];
    $lastword = $_GET['lastword'];
    $imagefile = $_GET['imagefile'];
    if($imagefile == ''){
    $imagefile = 'nopic';
    }else {

    }
    mysql_query("insert into notes (content,author,date,lastword,image) values('".$content."','".$author."',NOW(),'".$lastword."','".$imagefile."')");
    sleep(1);
    if(is_dir("../tmpImage")){
    //die('tongguo');
    }
    $path = dirname(__FILE__).'/'.$imagefile;
    if(!chmod ($path, 0755)){
    die('buhaoshi');
    }
    //var_dump($path);
    if(!file_exists($path));
    { die($path);
    }
    die('guola');
    if($imagefile != 'nopic' && file_exists("../tmp_image/".$imagefile)){

    rename("../tmp_image/".$imagefile, "../upload/".$imagefile);
    }
    header("Location: ../index.php?lastword=".$lastword);
      

  5.   

    if($this->Is_uploadDir() && $this->Is_FileMax())
              {
                  $this->get_newname();
                  $file_path=$this->g_Directroy.'/'.$this->g_doUpFile;
      if(!move_uploaded_file($_FILES[$this->g_filename]['tmp_name'], $file_path))
                  {
                        $this->g_Error=5;
                        return $this->get_error();
                  } 
                  else 
                  {
         
                      $this->g_Error=0;
                      return $this->get_error(); 
                  }
      

  6.   

    你都 die('guola'); 了,rename还有可能执行吗?