3
I’m trying to make a scheme with YII framework fileField so that when a user clicks on the image on the screen, the name of the clicked image will appear in span and the model value in fileField will receive the image. But I’m not getting fileField to receive this image by clicking.
Here is the snippet of fileField code:
<span class="form-control"></span>
<span class="input-group-btn">
<?php echo $form->fileField($model,'des_imagem', array('id' => 'imagemxd', 'style' => 'width: 60%', 'value' => 'text', 'onchange'=>'$(this).parent().parent().find(".form-control").html($(this).val().split(/[\\\|/]/).pop());', 'style'=>'display: none;','name'=>'produto_image','accept'=>'image/*')); ?>
Here is the code snippet from the image:
echo CHtml::image($string, '', array( 'onclick' => "$(this).parent().find('input[type=image]').click();", 'id' => 'cimagem', 'style' => 'width: 50%;' ));
NOTE: I don’t know if something changes for this question, but everything is in the same div.
Apparently you are trying to display the image without first uploading it. You will not be able to display it this way, with the image still in the client.
– Marcelo de Andrade
How so upload? Because uploading the image only occurs after I click on a save button. My idea was for it to appear in span as soon as it clicked. I’m sorry if I’m talking nonsense but I’m new to Yii.
– Ahri Main