Skip to main content

Posts

Showing posts from October, 2017

Yii : Image resize before ajax upload

File input control in form: <div class="row"> <img id="preview" width="200px" class="hidden"/> <?php echo CHtml :: label ( "File Foto" , 'file_image' ); ?> <?php echo CHtml :: fileField ( "file_image" , '' , array ( 'accept' => '.jpg' )); ?> <br/> <?php echo CHtml :: button ( "Upload Foto" , array ( 'id' => 'btn-upload' )); ?> </div> Button onclick event: Yii::app()->clientScript->registerScript('upload', " $('#btn-upload').click(function(){ resizeImage(); }); "); Javascript function : < script > function upload(dataurl) { var formData = new FormData($( "#tbl-hdrclaimrusak-form"...

Yii : Image preview before upload

File input control in form: <div class="row"> <img id="preview" width="200px" class="hidden"/> <?php echo CHtml :: label ( "File Foto" , 'file_image' ); ?> <?php echo CHtml :: fileField ( "file_image" , '' , array ( 'accept' => '.jpg' )); ?> <br/> <?php echo CHtml :: button ( "Upload Foto" , array ( 'id' => 'btn-upload' )); ?> </div> Javascript onchange event: Yii::app()->clientScript->registerScript('preview', " $('#file_image').change(function(){ var file_name=$('#file_image').val(); var extension=file_name.split('.').pop(); if(extension=='jpg'||extension=='JPG'||extension=='jpeg'||extension...