Revision #2 has been created by rsingh on Apr 17, 2011, 9:32:50 AM with the memo:
copy/paste error for $pic->name
« previous (#1) next (#3) »
Changes
Title
unchanged
Uploading multiple images with CMultiFileUpload
Category
unchanged
How-tos
Yii version
unchanged
Tags
unchanged
CMultiFileUpload, File upload, image, saveAs
Content
changed
[...]
if (isset($images) && count($images) > 0) {
// go through each uploaded image
foreach ($images as $image => $pic) {
echo $pic->name.'<br />';
if ($pic->saveAs(Yii::getPathOfAlias('webroot').'/images/ADD YOUR PATH HERE!/'.$modelpic->name)) {
// add it to the main model now
$img_add = new Picture();[...]
```
Obviously, you have to handle the errors, but that's up to you (I haven't coded that yet). However, now you have the files uploaded to your model, and you can play around with it
Hat-tip: **Wiseon3** caught a copy/paste error of mine:
```php
"if ($pic->saveAs(Yii::getPathOfAlias('webroot').'/images/ADD YOUR PATH HERE!/'.$model->name)) {
// add it to the main model now"
```
has been updated to
```php
if ($pic->saveAs(Yii::getPathOfAlias('webroot').'/images/ADD YOUR PATH HERE!/'.$pic->name)) {
// add it to the main model now
```
The main code has been updated to reflect this change. Thanks