web/BaseWebFile.php
public function synchronize()
    {
        if (empty($this->_fileSubpath)) {
            $file = empty($this->_destFilePath) ? $this->fileUrl : $this->_destFilePath;
            $this->errmsg = __METHOD__ . "({$this->fileUrl}): "
                . Yii::t($this->tc, "File '{file}' is not from upload mirror area", ['file' => $file]);
            return false;
        }

        $ext = $this->isAllowedExtension();
        if ($ext !== true) {
            $this->errmsg = Yii::t($this->tc, "File has not allowed type '{ext}'", ['ext' => $ext]);
            return false;
        }

        if (!is_file($this->_srcFilePath)) {
            $this->errmsg = Yii::t($this->tc, "Source file '{file}' not found", ['file' => $this->_srcFilePath]);
            return false;
        }

        $needUpdate = $this->needUpdate($this->_srcFilePath, $this->_destFilePath);
        if (is_file($this->_destFilePath)) {
            if ($needUpdate && !@unlink($this->_destFilePath)) {
                $this->errmsg = Yii::t($this->tc, "Can't delete file '{file}'", ['file' => $this->_destFilePath]);
                return false;
            }
        }

        $result = $this->copyFile($this->_srcFilePath, $this->_destFilePath);
        if ($result === false) {
           $this->errmsg = $this->errmsg ?: Yii::t($this->tc, "Can't copy file");
           return false;
        }
        $this->_fileBody = file_get_contents($this->_destFilePath); // new content

        return true;
    }
public function synchronize()
    {
        if (empty($this->_fileSubpath)) {
            $file = empty($this->_destFilePath) ? $this->fileUrl : $this->_destFilePath;
            $this->errmsg = __METHOD__ . "({$this->fileUrl}): "
                . Yii::t($this->tc, "File '{file}' is not from upload mirror area", ['file' => $file]);
            return false;
        }

        $ext = $this->isAllowedExtension();
        if ($ext !== true) {
            $this->errmsg = Yii::t($this->tc, "File has not allowed type '{ext}'", ['ext' => $ext]);
            return false;
        }

        if (!is_file($this->_srcFilePath)) {
            $this->errmsg = Yii::t($this->tc, "Source file '{file}' not found", ['file' => $this->_srcFilePath]);
            return false;
        }

        $needUpdate = $this->needUpdate($this->_srcFilePath, $this->_destFilePath);
        if (is_file($this->_destFilePath)) {
            if ($needUpdate && !@unlink($this->_destFilePath)) {
                $this->errmsg = Yii::t($this->tc, "Can't delete file '{file}'", ['file' => $this->_destFilePath]);
                return false;
            }
        }

        $result = $this->copyFile($this->_srcFilePath, $this->_destFilePath);
        if ($result === false) {
           $this->errmsg = $this->errmsg ?: Yii::t($this->tc, "Can't copy file");
           return false;
        }
        $this->_fileBody = file_get_contents($this->_destFilePath); // new content

        return true;
    }
public function synchronize ( ) { if ( empty ( $ this -> _fileSubpath ) ) { $ file = empty ( $ this -> _destFilePath ) ? $ this -> fileUrl : $ this -> _destFilePath ; $ this -> errmsg = __METHOD__ . "({$this->fileUrl}): " . Yii :: t ( $ this -> tc , "File '{file}' is not from upload mirror area" , [ 'file' => $ file ] ) ; return false ; } $ ext = $ this -> isAllowedExtension ( ) ; if ( $ ext !== true ) { $ this -> errmsg = Yii :: t ( $ this -> tc , "File has not allowed type '{ext}'" , [ 'ext' => $ ext ] ) ; return false ; } if ( ! is_file ( $ this -> _srcFilePath ) ) { $ this -> errmsg = Yii :: t ( $ this -> tc , "Source file '{file}' not found" , [ 'file' => $ this -> _srcFilePath ] ) ; return false ; } $ needUpdate = $ this -> needUpdate ( $ this -> _srcFilePath , $ this -> _destFilePath ) ; if ( is_file ( $ this -> _destFilePath ) ) { if ( $ needUpdate && ! @ unlink ( $ this -> _destFilePath ) ) { $ this -> errmsg = Yii :: t ( $ this -> tc , "Can't delete file '{file}'" , [ 'file' => $ this -> _destFilePath ] ) ; return false ; } } $ result = $ this -> copyFile ( $ this -> _srcFilePath , $ this -> _destFilePath ) ; if ( $ result === false ) { $ this -> errmsg = $ this -> errmsg ? : Yii :: t ( $ this -> tc , "Can't copy file" ) ; return false ; } $ this -> _fileBody = file_get_contents ( $ this -> _destFilePath ) ; // new content return true ; }
Synchronize file from uploads area to web root files area.
@return boolean return true if
Synchronize file from uploads area to web root files area .