I have a problem. The $_FILES array is not the same using Yii and using plaing HTML…
To explain…
I’ve set up a test page with 3 upload slots:
<form name="upload_form" action="" method="post" enctype="multipart/form-data">
file1: <input type="file" name="file1" /><br>
file2: <input type="file" name="file2" /><br>
file3: <input type="file" name="file3" /><br>
<input type="submit" value="Submit" /><br>
</form>
The received array is STANDARD, according to the PHP documentation
_FILES: array(
[file1] => array(
[name] => 1112.jpg
[type] => image/jpeg
[tmp_name] => C:\Windows\Temp\php621A.tmp
[error] => 0
[size] => 131733
)
[file2] => array(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
[file3] => array(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
)
On x controller, y view, the user canwants to upload his/her id. The $_FILES array is DIFFERENT:
array(
[ACC_Avatar] => array(
[name] => array(
[avatarfile] => 1112.jpg
)
[type] => array(
[avatarfile] => image/jpeg
)
[tmp_name] => array(
[avatarfile] => C:\Windows\Temp\phpF27B.tmp
)
[error] => array(
[avatarfile] => 0
)
[size] => array(
[avatarfile] => 131733
)
)
)
Generated by:
$form=$this->beginWidget('CActiveForm', array('htmlOptions'=>array('encType'=>'multipart/form-data'),'clientOptions'=>array('validateOnSubmit'=>true)));
echo $form->fileField($uploadavatar_model,'avatarfile',array('class'=>'large'));
echo $form->error($uploadavatar_model,'avatarfile');
echo CHtml::submitButton('Submit');
$this->endWidget();
What can be the problem???
I wrote an uploader class that takes standard, PHP doc. safe, arrays, and it isn’t working with yii.