I’m working on a project that uses Zend_Gdata, specifically Zend_Gdata_Photos, to manage photos in Google’s Picasa Web Albums. When the application went into its testing phase, the image upload functionality began to throw exceptions. While I could upload photos to Picasa without issue, my business partner John couldn’t upload any photos at all. The application kept throwing the following error:
Since the app worked fine for me, the issue didn’t seem to be with the code. After some frustrating, unproductive troubleshooting, I finally built a file upload mockup and ran the
$_FILES array through Zend_Debug::dump(). I discovered that while Firefox reports the MIME type of a jpg as “image/jpeg”, Internet Explorer reports the MIME type as “image/pjpeg.” Thanks a lot, Redmond.
As it turned out, the problem occurred when I tried to set the upload content type to “image/pjpeg”:
I resolved the issue by adding a test for the pjpeg MIME type before setting the content type. The new code looks like this:
1 2 3 4
The code snippets above come from an image upload helper method that I built (borrowing heavily from Cory Wiles) to make working with Zend_Gdata_Photos a little easier.
If you’re having similar problems uploading images, regardless of the method that you’re using, check that MIME type and see if that’s not the issue.