Difference between #4 and #9 of
Saving files to a blob field in the database

Revision #9 has been created by pc131 on Nov 3, 2010, 8:30:34 PM with the memo:

yyy
« previous (#4) next (#10) »

Changes

Title unchanged

Saving files to a blob field in the database

Category unchanged

Tips

Yii version unchanged

Tags unchanged

File upload

Content changed

[...]
### Edit the view:

In the view we can put:


 
 

```php
<div class="row">
[...]
### Displaying images:

In the view we put the code:
 
 
 
```php 
'value'=>CHtml::link(my_link_name,array('displaySavedImage','id'=>$model->primaryKey)),
 
```
 
 
So it generates link like http://myserver/yii/myapp/index.php?r=candidate/displaySavedImage&id=1
 
 
Where Candidate is current model.
 
 
To show thesaved image we can write an action:
 
 
 in Controller: ```php /** * Displays the preview of the photoOpens the dialog in browser to open/save the image. */ public function actionDisplaySavedImage() { $model=$this->loadModel($_GET['id']);
 
 
header('Pragma: public');
 
header('Expires: 0');
 
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
 
header('Content-Transfer-Encoding: binary');
 
header('Content-length: '.$model->cv_file_size
); header('Content-Type: '.$model->cv_file_type); header('Content-Disposition: attachment; filename='.$model->cv);
 
 
        
echo $model->cv_file_content; } ```
 
 
Note *$_GET\['id'\]* as passed argument of loadModel function.
5 2
17 followers
Viewed: 61 014 times
Version: 1.1
Category: Tips
Written by: zaccaria
Last updated by: zaccaria
Created on: Nov 3, 2010
Last updated: 7 years ago
Update Article

Revisions

View all history