I have a problem with the file upload function attached to my webapp. The code works fine in my localhost, but not on the real server that I already downloaded. and I changed the permissions on the directories to write.
if ($model->load(Yii::$app->request->post()))
{
$session = Yii::$app->session;
$user_id = $session->get('role');
$imageName = $model->Fname."_".$model->Lname;
$model->file = UploadedFile::getInstance($model, 'file');
if($model->file)
{
$model->password = crypt($model->repeatpassword,'$6$rounds=1212$16charactersalt');
$model->image = 'uploads/profile_image/'.$imageName.'.'.$model->file->extension;
$model->role = $user_id;
$model->save();
$model->file->saveAs( 'uploads/profile_image/'.$imageName.'.'.$model->file->extension );
}
return $this->goHome();
}


source
share