Subscribe RSS
Drupal Bug Fix: Image Uploads Nov 19

I keep coming across variations of the same basic PHP coding error.  Last time it was a Joomla FTP installer issue, this time it’s a Drupal upload issue.  This is becoming a real pet peeve…

In Drupal 6.5 (and probably others), in the file “includes/file.inc“, the function named “file_save_upload()” does things out of order.  It is used to validate an uploaded file, but it tries to perform checks on the uploaded file before it calls PHP’s “move_uploaded_file()” function to move it out of the temporary upload area and into the user’s file space.

Around line 549 in “includes/file.inc” you’ll find three blocks of code labeled “Call the validation functions.”, “Check for validation errors.”, and “Move uploaded files from PHP’s upload_tmp_dir…..”

Moving the third block of code up before the first block so that the file is first moved into place and then validated seem to do the trick.

Note: this is a quick and dirty fix that seems to work. It may or may not have side effects that I’m not aware of. I’m not really all that familiar with Drupal’s code so I make no promises.

Mark

Category: Uncategorized
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
Leave a Reply » Register / Log in