Yii 1.1.3 framework. Make and existing image to be uploaded like

79 Views Asked by At

I have a form with uploaded image:

<div class="row">
    <?php echo $form->labelEx($model, 'Image'); ?>
    <?php echo CHtml::activeFileField($model, 'Image'); ?>
    <?php echo $form->error($model, 'Image'); ?>
</div>

I have a task to add a default image (screenshot from cam that I get with curl). I put path to it in $image variable and then I output it:

echo CHtml::image($image,"default image",array('width'=>195, 'height'=>110,'id'=>'defaultCamShot'));

So when I create an entity, I do folowing in controller:

$image = CUploadedFile::getInstance($model, 'Image');

Is there any way to put there content of #defaultCamShot? So, what I want: check if $image in controller is NULL and if it is, somehow give it conteont of #defaultCamShot. Any suggestions?

1

There are 1 best solutions below

0
On

The simplest solution is when you curl the camshot to save the image to disk somewhere. Then in the controller simply load the saved image if the user does not provide an image.