The problem is that I can't get the CMultifileUpload instance in my controller/action, when I call this action using ajax
here is my code in my view
<?php $form=$this->beginWidget('CActiveForm', array('id' => 'form',
'enableAjaxValidation' => false, 'htmlOptions' => array('enctype' => 'multipart/form-data'),)); ?>
<div class="row">
<?php
$this -> widget('CMultiFileUpload', array('name' => 'wupload', 'accept' => 'zip', \
'duplicate' => 'Duplicate file!', // useful, i think
'denied' => 'Invalid file type', // useful, i think
'max' => 1
));
echo CHtml::button('upload', array('onclick'=>'send()',));
?>
</div>
<?php $this->endWidget(); ?>
here is my action in my controller
public function actionUpload(){
$file = CUploadedFile::getInstancesByName('wupload');
var_dump($file);
}
here is my script function
function send() {
var data = $("#form").serialize();
$.ajax({
type : 'POST',
url : 'upload',
data : data,
success : function(data) {
alert(data);
},
error : function(data) {// if error occured
alert("Error occured.please try again " + data);
},
dataType : 'html'
});
}
now all what I receive after the alert shows is this
array(0){
}
I can't see my selected files, unlike if I used normal submit button, every thing worked correctly, I need someone tell me what am I doing wrong here?