Yii Framework Forum: Image Upload Using Chtml Form - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Image Upload Using Chtml Form Rate Topic: -----

#1 User is offline   Yii123 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 46
  • Joined: 13-March 13

Posted 19 March 2013 - 12:44 PM

I am using CHtml form for uploading an image. This is the code
view.php
<div class="form">
    <?php echo CHtml::beginForm(); ?>

    <div class="row">
        <?php echo CHtml::activeLabel($model, 'image'); ?>
        <?php echo CHtml::activeFileField($model, 'image') ?>
        <?php //echo Chtml::error($model, 'name'); ?>
    </div>
    <div class="row submit">
        <?php echo "<br>" . CHtml::imageButton(Yii::app()->request->baseUrl . '/images/upload.png', array('submit' )); ?>
    </div>

    <?php echo CHtml::endForm(); ?>
</div><!-- form -->


my doubt is, where i put this following code in this view.
//form options array...
'htmlOptions' => array(
        'enctype' => 'multipart/form-data',
    ),


Thanks
0

#2 User is offline   Amy 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 22
  • Joined: 04-February 13

Posted 19 March 2013 - 12:57 PM

that goes in the form:

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'picture-form',
	'enableAjaxValidation'=>false,
	'htmlOptions'=>array('enctype'=>'multipart/form-data')
)); ?>

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users