thilip.xandy Posted March 25, 2014 Share Posted March 25, 2014 (edited) Hi, Problem with image uploading for products, I have code which working correctly for one image, but not working good when we go with more than one image, here is my code, any one please help me thanks in advance. $image->id_product = intval($product->id); $image->position = Image::getHighestPosition($product->id) + 1; $languages = Language::getLanguages(); foreach ($languages as $language) $image->legend[$language['id_lang']] = $name; $id_image = $image->id; $imagesTypes = ImageType::getImagesTypes('products'); for ($i=0; $i< count($_FILES['design']['name']) ; $i++) { if(Image::getImagesTotal($product->id)>0) $image->cover = false; else $image->cover = true; $image->add(); $new_path[$i] = $image->getPathForCreation(); $tmpName = tempnam(_PS_IMG_DIR_, 'PS'); ImageManager::resize($tmpName, $new_path[$i].'.'.$image->image_format); foreach ($imagesTypes as $imageType){ //$new_path = $image->getPathForCreation(); ImageManager::resize($tmpName[$i], $new_path[$i].'-'.stripslashes($imageType['name']).'.'.$image->image_format, $imageType['width'], $imageType['height'], $image->image_format); move_uploaded_file($_FILES['design']['tmp_name'][$i], $tmpName); } } Edited March 25, 2014 by thilip.xandy (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts