Answer the question
In order to leave comments, you need to log in
YII2 "failed to open stream: No such file or directory" How to fix?
My class for working with images:
And its use:
After that everything is fine
But as soon as I write to save the image in a certain directory
, the following error pops up
even if I change and put a slash before uploads
$file->saveAs(Yii::getAlias('@web').'/uploads/'.$file->name);
Answer the question
In order to leave comments, you need to log in
@webroot points to the root of the application, you need to use it:
$file->saveAs(Yii::getAlias('@webroot').'/uploads/'.$file->name);
Is the image saved?
Try this:
alias
preservation
Also check the write permissions to the directory.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question