move_uploaded_file(): failed to open stream: No such file or directory
модель
<?php
namespace app\models;
use Yii;
use yii\base\Model;
use yii\web\UploadedFile;
class ImageUpload extends Model{
public $image;
public function uploadFile(UploadedFile $file)
{
$file->saveAs(Yii::getAlias('@web/') . 'uploads/' . $file->name);
}
}
контроллер
public function actionSetImage ($id)
{
$model = new ImageUpload;
if(Yii::$app->request->isPost)
{
$file = UploadedFile::getInstance($model, 'image');
$model -> uploadFile($file);
}
return $this->render('image',['model'=>$model]);
}
директория для загрузки: .../web/uploads
дамп
object(yii\web\UploadedFile)#71 (5)
{ ["name"]=> string(9) "image.png"
["tempName"]=> string(19) "/virt/tmp/phpxZ2XOl"
["type"]=> string(9) "image/png"
["size"]=> int(862331)
["error"]=> int(0) }