public function actionView($id) { $model = tblGallery::findOne($id); if ($model->load($_POST)) { $files = \yii\web\UploadedFile::getInstances($model, 'upload_files'); if (isset($files) && count($files) > 0) { $mPath = \Yii::getAlias('@webroot') . '/images/gallery/cat_' . $id; if (!is_dir($mPath)) { mkdir($mPath); chmod($mPath, '777'); } foreach ($files as $file) { $mPic = substr(number_format(time() * rand(), 0, '', ''), 0, 14) . '.' . $file->extension; //Upload Images if ($file->saveAs($mPath . '/' . $mPic)) { $image = \Yii::$app->image->load($mPath . '/' . $mPic); $image->resize(1024, 1024); $image->save($mPath . '/' . $mPic); //resize images thumb $image = \Yii::$app->image->load($mPath . '/' . $mPic); $image->resize(250, 250); $mThumb = $mPath . '/thumb/'; if (!is_dir($mThumb)) { mkdir($mThumb); chmod($mThumb, '777'); } $image->save($mThumb . $mPic); } } } } return $this->render('view', ['model' => $model]); }
public function actionView($id) { $counter = new counter(); $counter->hitsCounter('gallery/view', $id); $model = tblGallery::findOne($id); $gallery = new tblGallery(); return $this->render('view', ['model' => $model, 'gallery' => $gallery]); }