src/helpers/Storage.php
public static function replaceFile($fileName, $newFileSource, $newFileName)
    {
        try {
            Yii::$app->storage->ensureFileUpload($newFileSource, $newFileName);
        } catch (\Exception $e) {
            return false;
        }

        return Yii::$app->storage->fileSystemReplaceFile($fileName, $newFileSource);
    }
public static function replaceFile($fileName, $newFileSource, $newFileName)
    {
        try {
            Yii::$app->storage->ensureFileUpload($newFileSource, $newFileName);
        } catch (\Exception $e) {
            return false;
        }

        return Yii::$app->storage->fileSystemReplaceFile($fileName, $newFileSource);
    }
public static function replaceFile ( $ fileName , $ newFileSource , $ newFileName ) { try { Yii :: $ app -> storage -> ensureFileUpload ( $ newFileSource , $ newFileName ) ; } catch ( \ Exception $ e ) { return false ; } return Yii :: $ app -> storage -> fileSystemReplaceFile ( $ fileName , $ newFileSource ) ; }
Replace the source of a file on the webeserver based on new and old source path informations.

The replaced file will have the name of the $oldFileSource but the file will be the content of the $newFileSource.

@param string $fileName The filename identifier key in order to find the file based on the locale files system.
@param string $newFileSource The path to the new file which is going to have the same name as the old file e.g. `path/of/new.jpg`.  $_FILES['tmp_name']
@param string $newFileName The new name of the file which is uploaded, mostly given from $_FILES['name']
@return boolean Whether moving was successfull or not.
Replace the source of a file on the webeserver based on new and old source path informations .