public function move($toDir, $fileName = null, $mode = 0775)
    {
        if ($this->hasError()) {
            throw new \Exception('Cannot move file, the file has not been correctly uploaded!');
        }

        $fileName = (empty($fileName) ? $this->get('name') : $fileName);

        if (!file_exists($toDir) && !mkdir($toDir, $mode, true)) {
            throw new \Exception(__METHOD__ . '|Cannot create directory "' . $toDir . '" !', 1000);
        }

        return move_uploaded_file($this->get('tmp_name'), $toDir . $fileName);
    }
public function move($toDir, $fileName = null, $mode = 0775)
    {
        if ($this->hasError()) {
            throw new \Exception('Cannot move file, the file has not been correctly uploaded!');
        }

        $fileName = (empty($fileName) ? $this->get('name') : $fileName);

        if (!file_exists($toDir) && !mkdir($toDir, $mode, true)) {
            throw new \Exception(__METHOD__ . '|Cannot create directory "' . $toDir . '" !', 1000);
        }

        return move_uploaded_file($this->get('tmp_name'), $toDir . $fileName);
    }
public function move ( $ toDir , $ fileName = null , $ mode = 0775 ) { if ( $ this -> hasError ( ) ) { throw new \ Exception ( 'Cannot move file, the file has not been correctly uploaded!' ) ; } $ fileName = ( empty ( $ fileName ) ? $ this -> get ( 'name' ) : $ fileName ) ; if ( ! file_exists ( $ toDir ) && ! mkdir ( $ toDir , $ mode , true ) ) { throw new \ Exception ( __METHOD__ . '|Cannot create directory "' . $ toDir . '" !' , 1000 ) ; } return move_uploaded_file ( $ this -> get ( 'tmp_name' ) , $ toDir . $ fileName ) ; }
Move uploaded file.

@param  string $toDir
@param  string $fileName
@param  int    $mode Right mode on directory to create (if not exists)
@return bool
@throws \Exception
Move uploaded file .