Saturday, December 11, 2010

Drupal image file upload - can not select any images

Attempting to upload an image file to my Drupal site this morning, I encountered one of those bugs that brings an early Saturday morning of productive coding to a grinding halt. Despite already having successfully uploaded a handful of images, the files were suddenly greyed-out and inactive. I ran through 20-30 minutes of troubleshooting my user permissions and file directory settings to no avail. It felt like one of those strange issues that only I had run into, so I didn't have much hope for finding the answer on Drupal.org (spoiler alert - I did find the answer, and you will too!).

Lucky for me, there had already been a great deal of discussion, and the issue was apparently caused by an update to Google Chrome 8 (8.0.552.11 dev, to be specific). It's important to note that it wasn't technically a bug on Chrome's part, rather the fact that it updated the way it implements HTML5 file uploads. Instead of accepting file extensions (which is what the Drupal ImageField and FileField modules provide), the browser (correctly, according to the HTML5 specification, BTW) now expects mime types.

I suspect this issue will be affecting a lot of Drupal developers over the next few days, and while the issue is directly related to an update with Google Chrome, it would be very easy for a developer to go search Drupal.org for problems with the image file upload before thinking to check it in another browser. I'm simply creating this page as a gateway to the solution that might more closely match the search terms of a bewildered developer.

If you are having the problem of not being able to select files to upload to your Drupal site using Google Chrome, you will want to take a look at this article on Drupal.org. If you're in a real hurry, I'll give you the solution (that worked for me) right now, but I strongly suggest reading up on the issue before implementing this fix, especially on a production environment.

After all the patches and workarounds suggested over the past few weeks, the true solution surfaced, and it involved an update to the two affected Drupal modules: Filefield and Imagefield. Go grab the latest versions of those (6.x-3.8 for both), or run this command through Drush:

pm-update filefield imagefield

Let me know if you found this solution helpful; and by all means head on over to Drupal.org and give those guys some love for the quick, solid solution. Once again, I am amazed by the effective collaboration in the community of Drupal Web builders.