Advertisement
MadeCurler

File exists after deletion

Dec 17th, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.92 KB | None | 0 0
  1. public function save(){
  2.  
  3.     //var_dump($_FILES['file_upload']);
  4.     if($this->id){
  5.         $this->update();
  6.     } else{
  7.             if(!empty($this->errors)){
  8.             return false;
  9.             }
  10.  
  11.             if(empty($this->filename)|| empty($this->tmp_path)){
  12.             $this->errors[]="The file was not available";
  13.             return false;
  14.             }
  15.  
  16.             $target_path=SITE_ROOT.DS.'admin'.DS.$this->upload_directory.DS.$this->filename;
  17.  
  18.             //echo $target_path;
  19.  
  20.     /* The problem is here but I can't find it - If I comment this out
  21.        I can upload the same file multiple times*/
  22.         if(file_exists($target_path)){
  23.         $this->errors[]="The file {$this->filename} already exists";
  24.         return false;
  25.         }
  26.  
  27.             if(move_uploaded_file($this->tmp_path,$target_path)){
  28.                     if($this->create()){
  29.                         unset($this->tmp_path);
  30.                         return true;
  31.                     }
  32.             } else{
  33.                 $this->errors[]="Check File Permissions!!";
  34.                 return false;
  35.             } // end inner else
  36.            
  37.     } // end else
  38. } // end save
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement