jowen
(Ljowen985)
August 9, 2011, 6:47am
1
Hi guy,
i can upload pic to database by refer to file to database. but how i can display the pic from view site after save to database… The wiki show how to display image step. but i not really understand the following code, what the my_link_name stand for?
Displaying images: ¶
[b]In the view we put the code:
[/b]
<? echo CHtml::link(my_link_name,array(‘displaySavedImage’,‘id’=>$model->primaryKey)); ?
Help help. anyone can help me??
Thank.
Y11
(Y!!)
August 9, 2011, 7:47am
2
It’s just the link text. You can do this:
<? echo CHtml::link("Click here to view image",array('displaySavedImage','id'=>$model->primaryKey)); ?>
Note that you have to implement the actionDisplaySavedImage method into your controller. It’s in the wiki as well.
joblo
(Joe)
August 9, 2011, 7:59am
3
Please take a look at the class references if you not understand a code: CHtml::link
This code displays a link with the ‘my_link_name’ as text to show the image:
echo CHtml::link('Show the image',array('displaySavedImage','id'=>$model->primaryKey));
If you want to see the image immediatly you can add following code:
$imageUrl = $this->createUrl('displaysavedimage',array('id'=>$model->primaryKey));
echo CHtml::image($imageUrl);
jowen
(Ljowen985)
August 9, 2011, 8:10am
4
thank for the reply… i try to do it now… Thank again. =)
jowen
(Ljowen985)
August 9, 2011, 8:28am
5
Hi Joblo,
If you want to see the image immediatly you can add following code:
$imageUrl = $this->createUrl('displaysavedimage',array('id'=>$model->primaryKey));
echo CHtml::image($imageUrl);
i put this code inside controller or view side??
thank…
joblo
(Joe)
August 10, 2011, 8:39am
6
This code is in the view.
In a controller action normally no output (echo, CHtml::XX …) should be generated.