----------controller------------
use yii\web\UploadedFile;
//****************** rutina de almacenar la imagen********************************
$image = UploadedFile::getInstance($model, ‘image’);
// generate a unique file name to prevent
if (!is_null($image)) {
$model->agenciafotosrcfilename = $image->name;
$image->name = strtr($image->name, " “, “-”);
// busca la extencion del archivo
$ext = explode(”.“, $image->name);
$ext = end($ext);
// generate a unique file name to prevent duplicate filenames
$model->agenciafotowebfilename = Yii::$app->security->generateRandomString().”.{$ext}";
// the path to save file, you can set an uploadPath
// in Yii::$app->params (as used in example below)
Yii::$app->params[‘uploadPath’] = Yii::$app->basePath . ‘/web/images/agencias/’;
$path = Yii::$app->params[‘uploadPath’] . $model->agenciafotowebfilename;
$image->saveAs($path);
}
//*************************************************************************************