【发布时间】:2017-12-08 05:01:58
【问题描述】:
当我在 gridview 中单击缩略图时,我想查看原始图像。
$file = 'http://localhost/myapp/upload/item_original/'.$model->image;
$type = 'image/jpg';
header('Content-Type:'.$type);
header('Content-Length: ' . filesize($file));
readfile($file);
我尝试了上面的代码,但没有成功。 然后我尝试了easyimage扩展。
public function actionViewImg($id){
$model = $this->loadModel($id);
Yii::import('application.extensions.easyimage.EasyImage');
$image = new Image('http://localhost/obhre/upload/item_original/1235.jpg'); //get the image
$image->save('upload/viewimg/1235.jpg');//save it to another folder
echo Yii::app()->easyImage->thumbOf('upload/viewimg/1235.jpg'); //view the image
}
如果我放置相对路径,上面的代码就可以工作。但不能使用绝对路径。 错误是“没有图像”
【问题讨论】: