I am trying to upload file inside CjuiDialog widget, I am printing the uploaded file name in Controller class but it returns null, i tried to print $POST array, the image array returns empty, Please see below code,
My Controller Code,
public function actionUpload()
{
$model=new UploadModel();
echo var_dump($_POST);
if(isset($_POST['UploadModel']))
{
$model->image=CUploadedFile::getInstance($model,'image');
echo"image-->".$model->image;
$this->redirect(array("create"));
}
}
My View Code,
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'uploadfile-form',
//'enctype'=>'multipart/form-data',
'method'=>'post',
'htmlOptions' => array('enctype' => 'multipart/form-data'),
'action'=>'upload',
// Please note: When you enable ajax validation, make sure the corresponding
// controller action is handling ajax validation correctly.
// There is a call to performAjaxValidation() commented in generated controller code.
// See class documentation of CActiveForm for details on this.
'enableAjaxValidation'=>false,
)); ?>
<p class="note">Fields with <span class="required">*</span> are required.</p>
<?php
echo $form->errorSummary($model); ?>
<?php echo $form->labelEx($model,'Base Name',array('text-align'=>'right','style'=>'display:inline-block'))." "; ?>
<?php echo $form->textField($model,'name',array('size'=>60,'maxlength'=>128)); ?>
<?php echo $form->error($model,'name'); ?>
<br>
<?php echo $form->labelEx($model,'Active',array('style'=>'display:inline-block'))." "; ?>
<?php echo $form->checkBox($model,'is_active',array('size'=>60,'maxlength'=>128)); ?>
<?php echo $form->error($model,'is_active'); ?>
<br>
<?php
echo $form->fileField($model, 'image');
?>
<br><br>
<?php echo CHtml::submitButton( 'Upload',array('background-style'=>'none')); ?>
<?php echo CHtml::button('Cancel',array('background-style'=>'none','onclick'=>'$("#BCEditSource").dialog("close"); return false;')); ?>
<?php $this->endWidget(); ?>