我在Yii2框架中的上传/更新功能有问题。 p>
我的更新功能: p>
public function actionUpdate($ id){
$ model = $ this-> findModel($ id);
// $ model-&gt ; scenario ='update';
if if($ model-> load(Yii :: $ app-> request-> post())&& $ model-> save()){
$ uploadDir = Yii :: getAlias('@ web / web / uploads')。 Yii :: getAlias('@ web / web / uploads');
$ uploadPath = Yii :: getAlias('@ web / web / uploads');
$ model-> save();
$ imageProject = $ model-> id;
//主图像
$ image = UploadedFile :: getInstance($ model,'main_image');
if($ image){
$ imgProject ='project_'。 $ imageProject。 '' 。 $ image-> getExtension();
$ image-> saveAs($ uploadDir。'/'。$ imgProject);
$ model-> main_image = $ uploadPath。 '/'。 $ imgProject;
}
if($ model-> upload()){
$ model-> save();
返回$ this-> redirect(['view', 'id'=> $ model-> id]);
} else {
返回$ this-> render('update',[
'model'=> $ model,
]) ;
}
}其他{
返回$ this-> render('update',[
'model'=> $ model,
]);
}
}
code> pre>
我的params.php文件: p>
返回[
'aliases'=> [
'@ projectImgPath'=> '@ webroot / web / uploads',
'@ projectImgUrl'=> '@ web / web /'
]
code> pre>
]; p>
当我在表单中上传文件时,我有这个 错误: p>
move_uploaded_file(/web/uploads/web/uploads/gallery_1_3.png):无法打开流:没有这样的文件或目录
code> pre>
任何人都可以帮助我......谢谢! p>
div>