uploading multiple images for same node

kuldeepkaundal - November 9, 2009 - 10:32

Hi,

Is it possible to upload mutiple images for same node while adding content using image module, e.g.,

Suppose we have those three fields in our form:

<?php
   $form
['image'] = array(
                         
'#type' => 'file',
                         
'#title' => t('Photo1'),
                        
                         
'#description' => t('Click "Browse..." to select an image to upload.'));
                         
 
$form['image2'] = array(
                         
'#type' => 'file',
                         
'#title' => t('Photo2'),
                         
'#description' => t('Click "Browse..." to select an image to upload.'));  
 
 
$form['image3'] = array(
                         
'#type' => 'file',
                         
'#title' => t('Photo3'),
                         
'#description' => t('Click "Browse..." to select an image to upload.'));  
?>

and we are using following code to upload images:
<?php
if(function_exists('image_prepare') && function_exists('image_insert')){
     
   
image_prepare($node, 'image');
   
    if(
$node->images['_original'] != ''){
     
     
image_insert($node);
    }
   
     
image_prepare($node, 'image2');
   
    if(
$node->images['_original'] != ''){
     
     
image_insert($node);
    }
   
     
image_prepare($node, 'image3');
   
    if(
$node->images['_original'] != ''){
     
     
image_insert($node);
    } 
?>

Now this code uploads all the three images, but,i can only see the first one if i use following code to echo uploaded images:

<?php
echo $node->images;
?>

I see following output:

[images] => Array
(
[preview] => files/images/4clothing.preview.jpg
[thumbnail] => files/images/4clothing.thumbnail.jpg
[_original] => files/images/4clothing.jpg
)

Is there a way to get the other images as well?

Thanks,
Kul.

 
 

Drupal is a registered trademark of Dries Buytaert.