CUploadedFile possible bugs

Hello,

1st thing:

CUploadedFile::getInstance() method docs says that "…Null is returned if no file is uploaded for the specified model attribute", but if it was no file selected it returns not null, but CuploadedFile object with empty properties and error status = 4. Dont even know is it a bug / feature / documentation inaccuracy or my misunderstanding.

2nd thig:

if we have model tabular file inputs and not tabular at the same time CUploadedFile::getInstance() crashes with php error.

In this case $_FILES array looks like this:

[ProductImage] => Array


        (


            [name] => Array


                (


                    [0] => Array


                        (


                            [imageFile] => image1.jpg


                        )





                    [1] => Array


                        (


                            [imageFile] => image2.jpg


                        )





                    [someFile] => somefile.txt


                )


             ...


Could you create a ticket for this? For the 2nd issue, what is the PHP error you are seeing? And what do you mean "we have model tabular file inputs and not tabular at the same time" ?

[quote=qiang]Could you create a ticket for this?
[/quote]
You mean google code issue for the 1st thing i told?

[quote=qiang]For the 2nd issue, what is the PHP error you are seeing?
[/quote]
I got this error:

array_keys() [<a href=‘function.array-keys’>function.array-keys</a>]: The first argument should be an array

Z:homeyiiwwwmtmailframeworkwebCUploadedFile.php(75)

[quote=qiang]And what do you mean “we have model tabular file inputs and not tabular at the same time” ?
[/quote]
I mean something like that:

<?php

echo CHtml::beginForm('', 'post', array('enctype'=>'multipart/form-data'));

foreach ($testModels as $i=>$model)

echo CHtml::activeFileField($model, &quot;file&#91;$i&#93;&quot;);

echo CHtml::activeFileField($model, "file");

echo CHtml::submitButton();

echo CHtml::endForm();

?>

And controller like this:

<?php

if (isset($_POST['TestForm']))

{

$testModel = new TestForm;


$testModel-&gt;file = CUploadedFile::getInstance($testModel, &#039;file&#039;);

}

?>

In this case $_FILES array looks like i wrote in the 1st post.

I was find it out accidentally and i cant imagine application of this approach, but it crashes Yii and thats not good.

Yes, please create a google ticket for the whole issue. I will need time to investigate this. Thanks for the information!

Done

http://code.google.c…s/detail?id=368

http://code.google.c…s/detail?id=367