Jump to content

multiple image upload for product


Recommended Posts

Hi, I'm creating one module in that customer need to upload the image for product. If was working fine for single image, when we go for multiple image it is not working properly, only cover image was getting uploaded others are not getting uploaded here is my code

 

for ($i=0; $i< count($_FILES['design']['name']) ; $i++) {
                 $image->position = Image::getHighestPosition($product->id) + 1;
                if(Image::getImagesTotal($product->id)> 0)
                     $image->cover = false;
                else
                     $image->cover = true;
                $languages = Language::getLanguages();
                foreach ($languages as $language)
                $image->legend[$language['id_lang']] = $name;
                $id_image = $image->id;
                $image->add();

                $tmpName = tempnam(_PS_IMG_DIR_, 'PS');
                move_uploaded_file($_FILES['design']['tmp_name'][$i], $tmpName);
                $new_path = $image->getPathForCreation();
                ImageManager::resize($tmpName, $new_path.'.'.$image->image_format);
                $imagesTypes = ImageType::getImagesTypes('products');
                foreach ($imagesTypes as $imageType)
                ImageManager::resize($tmpName, $new_path.'-'.stripslashes($imageType['name'][$i]).'.'.$image->image_format, $imageType['width'][$i], $imageType['height'][$i], $image->image_format);
            }

 

 

thanks  in advance.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...