CActiveForm data format


I’m new to yii, and still struggling with some concepts.

The problem as I see it.

I’m implementing a form, with an image upload field. The form is generated by gii, and uses the CActiveForm widget.

The image needs to be resized to several sizes after upload, so I searched around and found an extension “cimagemodifier” that acts as a wrapper for Verot’s class.upload.php which I’m familiar with.

So far, so good.

The trouble appears when I try to pass the uploaded file to class.upload.

It expects the input to be in the form

$_FILES =>

Array (

[name] => imagename.jpg

[type] => image/jpeg

[tmp_name] => C:\Windows\Temp\phpFD04.tmp

[error] => 0

[size] => 458321


Insted I get from the form

$_FILES[‘User’] =>

Array (

[name] => Array ( [logo] => imagename.jpg )

[type] => Array ( [logo] => image/jpeg )

[tmp_name] => Array ( [logo] => C:\Windows\Temp\phpFD04.tmp )

[error] => Array ( [logo] => 0 )

[size] => Array ( [logo] => 458321 )


I came up with:

        $upfile = $_FILES['User'];



            foreach($upfile as $key=>&$value)


                $upfile[$key] = array_shift($value);




to convert the $_FILES array in the form I can use, but I believe I am missing something, and there must be a better way.

Thank you for your thoughts.

Hi. Once you uploaded your image file, why don’t you use WideImage?


I once wrote an extension that uses phpThumb. Not very spectacular, but if you need simple resizing and rotating it does the job:

Thank you bennouna and Haensel for your suggestions, I will look into them.