0
votes

I have created script to import products in bulk through csv file. Earlier it was working perfectly but now suddenly for some of the reason it's getting stopped in between and only few products get upload.

Error : Fatal error: Uncaught exception 'Mage_Core_Exception' with message 'Invalid image file type.' in /home/../public_html/app/Mage.php:595 Stack trace: #0 /home/../public_html/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Media.php(282): Mage::throwException('Invalid image f...') #1 /home/../public_html/app/code/core/Mage/Catalog/Model/Product.php(1042): Mage_Catalog_Model_Product_Attribute_Backend_Media->addImage(Object(Mage_Catalog_Model_Product), '/home/../...', Array, false, false) #2 /home/../public_html/import-products.php(341): Mage_Catalog_Model_Product->addImageToMediaGallery('/home/../...', Array, false, false) #3 {main} thrown in /home/../public_html/app/Mage.php on line 595

1
what is the code you're using? without it is quite difficult to understand the exception.... - sissy
script is lengthy which is i am not able to show full code. I can say that i am using magneto inbuilt methods to store the product data. I would post bit of the code for image save as below. - User132887

1 Answers

0
votes

The referenced image is not of the correct type (eg: jpg,png,gif..etc..). All you had to do was search the codebase for the error:

    $pathinfo = pathinfo($file);
    $imgExtensions = array('jpg','jpeg','gif','png');
    if (!isset($pathinfo['extension']) || !in_array(strtolower($pathinfo['extension']), $imgExtensions)) {
        Mage::throwException(Mage::helper('catalog')->__('Invalid image file type.'));
    }