I have an ActiveRecord model that I use to upload files. However when I upload a file in my action the code in below “if” section doesn’t run due to $model->load($request->post()) returning false:
$request = Yii::$app->request;
$model = new EventAttachments();
if ($model->load($request->post())) {
echo 'It works!';
}
I had noticed that this article uses isPost() instead of load($request->post()), but didn’t know why and since in my upload form I had other fields which I also wanted to be posted I thought I could use the load approach (which other articles use). Unfortunately load approach only works if user is posting at least one other field, so I have switched to isPost() and now things are working as expected.