backend/controllers/SiteController.php
/**
     * @param string $image
     * @return string
     * @throws BadRequestHttpException
     * @throws NotFoundHttpException
     */
@param string $image
@return string
@throws BadRequestHttpException
@throws NotFoundHttpException
@param string $image @return string @throws BadRequestHttpException @throws NotFoundHttpException
public function actionViewTestsImage($image, $image_dir)
    {
        $model = new TestsLogSearch();
        if ($model->load(['TestsLogSearch' => ['image' => $image, 'image_dir' => $image_dir]]) && $model->validate()) {
            $ret = $model->getImage();
            if ($ret['status']) {
                $this->layout = 'empty';
                Yii::$app->response->format = Response::FORMAT_RAW;
                $headers = Yii::$app->response->headers;
                $headers->removeAll();
                $headers->add('Content-Type', 'image/png');
                $headers->add('Content-Disposition', "inline; filename=\"{$model->image}.png\"");
                return file_get_contents($ret['path']);
            } else {
                throw new NotFoundHttpException('Image not found.');
            }
        } else {
            throw new BadRequestHttpException(Json::encode($model->getErrors()));
        }
    }
public function actionViewTestsImage ( $ image , $ image_dir ) { $ model = new TestsLogSearch ( ) ; if ( $ model -> load ( [ 'TestsLogSearch' => [ 'image' => $ image , 'image_dir' => $ image_dir ] ] ) && $ model -> validate ( ) ) { $ ret = $ model -> getImage ( ) ; if ( $ ret [ 'status' ] ) { $ this -> layout = 'empty' ; Yii :: $ app -> response -> format = Response :: FORMAT_RAW ; $ headers = Yii :: $ app -> response -> headers ; $ headers -> removeAll ( ) ; $ headers -> add ( 'Content-Type' , 'image/png' ) ; $ headers -> add ( 'Content-Disposition' , " inline; filename= \" { $ model -> image } .png \" " ) ; return file_get_contents ( $ ret [ 'path' ] ) ; } else { throw new NotFoundHttpException ( 'Image not found.' ) ; } } else { throw new BadRequestHttpException ( Json :: encode ( $ model -> getErrors ( ) ) ) ; } }
@param string $image
 @return string
 @throws BadRequestHttpException
 @throws NotFoundHttpException
@param string $image @return string @throws BadRequestHttpException @throws NotFoundHttpException
//return $ret['info'];