Strugling with Magento file upload
July 5th, 2009. Published under Technology. No Comments.
It was the first time I played with Magento. I wanted to create an online shop for a library in my city. I must admit, it is a real beast that can do everything you want when running this kind of website. It manages carts, orders, invoices, taxes, mailing lists, promotions, etc. It is highly customizable with template and layout files.
The task of customization of your shop is not a small one but you can find a lot of documentation about this on Google and Magento official website provide a nice introduction tutorial to help you with the task.
But there is one thing I lost many hours on to debug : the image uploader. Here was my problem… when I uploaded my pictures for a product, everything was fine… my files was on the right folder and the administration panel showed me the pictures. But when I browsed to the product page, the only picture I could see was the default placeholder image of Magento.
After many hours browsing Google and finding no solution, I started to debug directly the source code. I found that the function “imagecreatefromjpeg” doesn’t exist. A quick check on php.net showed me that it was a GD function. GD wasn’t loaded properly but I thougt I had it ! I did a quick check :
$ php -i | grep gd
Configure Command => ‘./configure’ ‘–with-apxs2=/usr/bin/apxs2′ ‘–with-gd’ ‘–with-mcrypt’ ‘–with-curl’ ‘–with-zlib’ ‘–with-mysql’ ‘–with-mysqli’ ‘–with-pdo-mysql’ ‘–enable-sockets’ ‘–enable-soap’ ‘–with-pdflib’ ‘–with-xmlrpc’ ‘–disable-cgi’ ‘–with-xsl’ ‘–enable-exif’ ‘–with-config-file-path=/etc’ ‘–without-pdo-sqlite’ ‘–enable-bcmath’
No sign of the module loaded, only the “–with-gd” switch. A search on Google showed me that I should add the switch :
–with-jpeg-dir –with-png-dir
After recompiling PHP, I could see the product images on my Magento installation, HOURA!
Even if it was all my fault if the images wouldn’t load, is it normal that Magento gived me no advices to solve my problem ?











