Hello,
I have a problem uploading several images:
In my view I have several textArea which are linked with a CHtml::activeFilefield (I also have tried with CHtml::FileField)
$cont=0;
foreach($myModel as $paso){
echo CHtml::label('Descripción','');
echo CHtml::textArea('MyModel[description][]',
$paso->description,
array('rows'=>2, 'cols'=>50, 'class'=>'span8','id'=>$paso->id)));
//echo CHtml::FileField('MyModel[imagen_file][]', '', array('size' => 50,'id'=>'MyModel_imagen_file'));
echo CHtml::activeFilefield ($paso, 'imagen_file', array('size' => 50,'id'=>'MyModel_imagen_file'.$cont));
}
In my controller:
$pasos=$_POST['MyModel'];
$images = CUploadedFile::getInstancesByName('MyModel');
All the images arrive to my controller, the problem I have, is how to know which image is linked with which textarea.
For example I have the next values:
TextArea1: Lorem ipsum 1…
Image1: Empty
TextArea2: Lorem ipsum 2…
Image2: Empty
TextArea3: Lorem ipsum 3…
Image3: MyFile.png
Debugging, in my $images array, I only have one image:
$images Array [1]
0 CUploadedFile
_name MyFile.png
_tempName D:\\wamp\\tmp\\phpC360.tmp
_type image/png
_size 11553
_error 0
So how can I know that "MyFile.png" is linked with TextArea3? Is it possible to add any params to CHtml::activeFilefield so I can identify which "activeFilefield" has an image?
Thanks in advance.