Hi,
I am trying to send images from the server to user using the sendFile function.
The Open With/Save dialog box pops up and asks to open/save the file but but it does not seem to be sending the file. When I try to open the image with my image browser app it has an error saying "The file does not appear to be a GIF." The size of the file in the property is 47 bytes which is the exact size of the full path string of the directory/file.
The images are stored in the file system and the file name, mime type and size are stored in a database table. I have no trouble displaying the image on a page, just downloading from filesystem is an issue.
My Controller:
.
.
public function actionDownloadImage()
{
$model=$this->loadModel($_GET['id']);
$fileDir=Yii::app()->request->baseUrl.'/images/Promotional/';
Yii::app()->request->sendFile(
$model->lg_image_name,
$fileDir.$model->lg_image_name,
$model->lg_image_mime
);
}
.
.
My Download Link:
.
.
<div class="view" id="promotional">
<div class="item-image">
<?php
echo CHtml::link("Download Image", array(
'downloadImage', 'id'=>$data->id));
?>
</div>
</div>
.
.
My downloadImage page:
<?php
$this->actionDownloadImage();
?>
Any help appreciated.
Thanks