Open panke216 opened 8 years ago
I have same question. can any one please answer this?
see my extension "easy-upload" for save images
with this upload function, i populate de database whit images name.
public function actionUpload($id) { $fileName = 'file'; $uploadPath = 'upload/imoveis'; $model = new Imagens();
if (isset($_FILES[$fileName])) {
$file = \yii\web\UploadedFile::getInstanceByName($fileName);
if ($file->saveAs($uploadPath . '/' . $file->name)) {
//Now save file data to database
$model->foto = $file->name;
$model->id_propriedade = $id;
$model->created_at = date('Y-m-d h:m:s');
$model->save();
echo \yii\helpers\Json::encode($file);
}
}else {
return $this->render('upload',['id' => $id]);
}
return false;
}
Can you help to explain how to save uploaded file path into the database table? Thanks!