public function upload() { foreach ($this->file as $file) { $galleryImges = new GalleryImages(); $galleryImges->vendorId = Yii::$app->user->id; $galleryImges->ipAdress = $_SERVER['REMOTE_ADDR'] ?: ($_SERVER['HTTP_X_FORWARDED_FOR'] ?: $_SERVER['HTTP_CLIENT_IP']); $imageName = rand(1000, 100000) . $file->baseName; $galleryImges->imageUrl = 'web/uploads/storegallery/' . $imageName . '.' . $file->extension; $galleryImges->save(); $file->saveAs(realpath(Yii::$app->basePath) . '/web/uploads/storegallery/' . $imageName . '.' . $file->extension); } }
public function actionRemovegallery() { $galleryId = $_GET['galleryid']; $model = GalleryImages::find()->where(['galleryId' => $galleryId])->one(); $model->delete(); return true; }