Upload files in Yii2 Improved Application

Hi, I am using Yii2 Improved Application in develope environment.

Everything has gone fine until I try to upload a file.

This error:

move_uploaded_file(localhost/yiiadvanced/backend/assets/uploads/file.pdf): failed to open stream: No such file or directory

I have tried:

$model->file->saveAs(Yii::$app->params[‘baseUrl’].’/uploads/’ . $model->file->baseName . ‘.’ . $model->file->extension);

$model->file->saveAs(Yii::$app->params[‘baseUrl’].’/assets/uploads/’ . $model->file->baseName . ‘.’ . $model->file->extension);

$model->file->saveAs(‘localhost/yiiadvanced/backend/assets/uploads/’ . $model->file->baseName . ‘.’ . $model->file->extension);

var_dump($model->file->baseName . ‘.’ . $model->file->extension); works fine.

So file exists and folders exists and all permission is chmod 777.

I am trying this example: http://www.yiiframework.com/doc-2.0/guide-input-file-upload.html

you may use url path that might not exists (always), try to use absolute file path to store file

example C:\xampp\htdocs\application\uploads. hope this solution works for you :)