Hey everyone
I have a little problem with CMultifileupload. Problem si with POSTing files to controller.
I have this very simple view (only for uploading files):
<?php
$form = $this->beginWidget(
'CActiveForm',
array(
'id' => 'upload-form',
'htmlOptions' => array('enctype'=>'multipart/form-data'),
'enableAjaxValidation'=>false,));
?>
<div class="row">
<?php echo $form->labelEx($model, 'sourceCode');?>
<?php echo //$form->fileField($model, 'sourceCode');?>
<?php
$this->widget('CMultiFileUpload', array(
'model'=>$model,
'name' => 'sourceCode',
'attribute'=> 'sourceCode',
'max'=>5,
'accept' =>'zip',
'duplicate' => 'Duplicate file!',
'denied' => 'Invalid file type',
));
echo $form->error($model,'sourceCode');
?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton('Submit'); ?>
</div>
<?php
$this->endWidget();?>
As you can see I have commented fileField because I am upgrading from 1 file to multiple file upload. But when I replaced it with CMultiFileUpload it didn’t even post to controller. I even tried as simple action controller as this:
public function actionUpload()
{
$model = new UploadSolutionForm();
if(isset($_POST['UploadSolutionForm']))
{
echo 'Got it!';
}
$this->render('solve',array('model'=>$model));
}
But with fileField it echoes the message, but when replaced with CMultiFileUpload it doesn’t. So there seems to be somethink wrong with POST I think.
Just to clarify it work perfectly fine with fileField.
Here is my UploadSolutionForm just in case:
public $sourceCode;
public function rules()
{
return array(
array('sourceCode', 'file', 'types'=>'zip', 'allowEmpty'=>false, 'wrongType'=>'Only .java, .cc and .zip files allowed'),
);
}
Anyone knows what’s wrong because this seems simple enough but for some reason it doesn’t work.
Help is very appreciated.