New to Drupal, Running 5.2.0
I've been able to get most things up and running ok - Gallery2 integrated, ImageMagick configured etc, but this bit has me stumped.
Whenever I try to >Create Content>>Image, I get the error message "Uploaded file is not a valid image. Only JPG, PNG and GIF files are allowed."

I have searched and found a few earlier posts with the same problem and tried the suggestions contained. I've removed and re-installed the Image module. I've tried the x-dev release. I've checked that the 'files' and 'upload_tmp' directories are set to 777 - Recursive
I've even done a complete Drupal clean re-install without the Gallery2 integration, but I still get the same message.
Strangely, if I use the >File attachments section of create image content, the same file uploads fine.
And yes, the files DO have valid extensions, I'm only trying .jpg's so far.

This problem has stopped me dead. Can any one suggest what else I can try?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

VM’s picture

insure lower case .jpg as well as upper case .JPG are both allowed in the extenstions.

GeoffD-1’s picture

all my file names (and extensions) are lowercase by habit, but I have re-entered the allowable extensions and included the uppercase variants anyway.

I can only wonder if it might be a permissions thing somewhere in setup that I'm not aware of?

drewish’s picture

it's not based on the file extension, it uses the PHP's getimagesize() function. if you're having a problem with that it's either a bad image or a broken PHP build... that or some sort of other error which is causing an empty path to be passed to getimagesize().

CheckeredFlag’s picture

I'm having the same trouble. I inserted some debugging lines into image.module to dump some variables/functions just before the return. It yielded some interesting information:

$field_name == 'image'
$file == 'stdClass::__set_state(array(
   'filename' => 'test.jpg',
   'filepath' => 'C:\\WINDOWS\\TEMP\\tmp3E.tmp',
   'filemime' => 'image/jpeg',
   'filesize' => 104893,
   'source' => 'image',
))'
$image_info == ''
$image_info['extension'] == ''

ini_get('upload_tmp_dir') == 'e:\php\Uploads'
file_directory_temp() == 'sites/project.xenos.org/tmp'

Drupal (or php) is successfully uploading my file, but placing it in the wrong temp directory and giving it a weird filename! I'm running Drupal in a WIMP environment (i.e. Windows 2003 with IIS and PHP 5.2.3 as an ISAPI extension).

Why would it want to upload anything to my Windows $TEMP directory? Either php's upload directory or Drupal's tmp directory should be used, but not $TEMP which is on my system disk, which is relatively small! I've confirmed that IIS has write permissions to both the php upload directory as well as the Drupal temp.

I'm wondering if this is even an issue with the Image module or if it might be a problem with the Drupal core or even php?

I'd be happy to debug further, but I'm not sure where to look next....

GeoffD-1’s picture

I've been plodding thru any possible areas that might be throwing this up and would like to ask if anyone else that has had this problem was running from a virtual host?
I am and have come across this in> sites/default/settings.php

* To override specific entries in the 'variable' table for this site,
* set them here. You usually don't need to use this feature. This is
* useful in a configuration file for a vhost or directory, rather than
* the default settings.php. Any configuration setting from the 'variable'
* table can be given a new value.
*
* Remove the leading hash signs to enable.
*/
# $conf = array(
# 'site_name' => 'My Drupal site',
# 'theme_default' => 'minnelli',
# 'anonymous' => 'Visitor',
# );

Could this be affecting things and any suggestions for> $conf = array( ?

CheckeredFlag’s picture

I discovered that this is actually the result of a bug in Drupal core that results in failed uploads on Windows.

See my post here: http://drupal.org/node/180126

Just apply the patch attached to that post.

Hope this helps.

FableForge’s picture

mmoreno, thank you so much, the moment I patched the file.inc file as described in your link, the image problem was fixed! Thanks again!

GeoffD-1’s picture

Status: Active » Fixed

Many Thanks to MMoreno

Your patch solved my problem too.

Anonymous’s picture

Status: Fixed » Closed (fixed)
maya45’s picture

Issue summary: View changes
FileSize
2.94 MB
maya45’s picture

FileSize
3.27 MB
4.91 MB
maya45’s picture

Component: image.module » image_gallery
Assigned: GeoffD-1 » maya45
Category: Support request » Plan