File uploading to uploads folder but not saving in the database, getting below error
Unknown Method – yii\base\UnknownMethodException Calling unknown method: app\models\UploadForm::save()
Below is my controller code
$name = $model->file->baseName . '.' .$model->file->extension;
$file = new UploadForm();
$file->image_name = $name;
$file->image_path = $name;
$file->save();
This is my model code
namespace app\models;
use yii\base\Model;
use yii\web\UploadedFile;
public function rules()
{
//echo "in";
return [
[['image'], 'file', 'skipOnEmpty' => false, 'extensions' => 'png, jpg, jpeg'],
['image_path','string'],
];
}
Can anyone help me? I am new to yii2
UploadFormdoesn't havesave()method but you are trying to call it. It's probably because theUploadFormextendsyii\base\Modelthat doesn't have thesave()method. You should explain more about what you are trying to do and maybe show a little bit more of your code.