Incorrectly reporting uploaded file is not a valid image.

Carlitus - March 29, 2007 - 11:16
Project:Image
Version:6.x-1.0-alpha3
Component:image.module
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

With the last version when i submit a new image drupal returns:

Uploaded file is not a valid image. Only JPG, PNG and GIF files are allowed

I've tried with jpeg and gif images. The images are really in this formats.

I've located the line, it's the 163 in image.module and i've put a var_dump

$image_info = image_get_info($file->filepath);
    echo "<p>Image_info</p><pre>";
    var_dump($image_info);
    echo "</pre>";
    if (!$image_info || !isset($image_info['extension'])) {
      form_set_error($field_name, t('Uploaded file is not a valid image. Only JPG, PNG and GIF files are allowed.'));
      return;
    }

When i submit a new image the var_dump it's executed twice:

Image_info

array(5) {
["width"]=>
int(16)
["height"]=>
int(16)
["extension"]=>
string(3) "gif"
["file_size"]=>
int(361)
["mime_type"]=>
string(9) "image/gif"
}

Image_info

bool(false)

#1

drewish - March 29, 2007 - 15:39
Title:Uploaded file is not a valid image.» Incorrectly reporting uploaded file is not a valid image.

Can you upgrade to the latest 5.x-1.x-dev version and verify that the error exists there too?

#2

BTG308 - March 29, 2007 - 16:10

The latest 5.x-1.x-dev version fixed this problem, for me.

However, I was urged to run update.php and when I did:

user warning: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'EXISTS (SELECT * FROM node n WHERE n.nid = image_attach.iid AND query: DELETE FROM image_attach WHERE NOT EXISTS (SELECT * FROM node n WHERE n.nid = image_attach.iid AND n.type = 'image') in /var/www/localhost/htdocs/drupal5/includes/database.mysql.inc on line 172.

The module still appears to be working, but I haven't really tested it yet.

#3

drewish - March 29, 2007 - 17:03

BTG308, you should be alright. that query was designed to clean out old unreferenced attach records. could you open up a separate issue for that and provide some details about your SQL server?

#4

Carlitus - March 30, 2007 - 07:07

With the lastest 5 dev it works well. Thanks :)

#5

drewish - March 30, 2007 - 15:55
Status:active» fixed

#6

dangibas - April 8, 2007 - 13:55

Getting the error with 5.x-1.0

"The uploaded file was not an image."

Without upgrading to 5.x-1.x-dev is there anyway to fix this problem? I ask because running update.php didn't fix the problem in my case and also because update.php does not seem to update to 5.x-1.x-dev, i presume because its not a stable release.

Thanks

#7

Charlie Sibbach - April 19, 2007 - 23:42
Status:fixed» active

I am getting this error with Drupal 5.1, bundled GD, PHP5, on an IIS 6.0 server. I have updated to the latest dev release (as of about 4 days ago), and it did not fix the problem. Is this an IIS compatibility issue possibly? What extra information can I provide to help figure this out?

#8

Charlie Sibbach - April 20, 2007 - 00:24

Just a quick troubleshooting follow up. I can use the image_import module to create image nodes just fine. I also updated to the April 17 (currently the latest version) dev version. I still can't create an image node in the normal way, though.

#9

drewish - April 20, 2007 - 06:02
Status:active» fixed

make sure you're not trying to upload files larger than PHP's file size limit.

#10

Stefan Nagtegaal - April 20, 2007 - 06:07
Priority:critical» normal
Status:fixed» needs work

If this error message is triggered when people try to upload a file which exceeds the PHP file_size limit, than that is a bug and needs fixing imo..
Re-opening as such..

Drewish/Walkah, feel free to enlighten me when you're going to close this issue without trying to fix it..

#11

drewish - April 20, 2007 - 06:18
Status:needs work» fixed

Stefan Nagtegaal, i guess i don't see why i need to "enlighten me when you're going to close this issue without trying to fix it"... the original issue was resolved. Carlitus, who opened the issue reported it was working. it was fixed. Charlie Sibbach, re-opens the issue and based on his comments i give him a suggestion and re-close the issue. if you want to open a new issue to warn users of the maximum file upload size feel free to do so. better yet attach a patch (instead of just flagging the issue as having a patch).

#12

Charlie Sibbach - April 21, 2007 - 00:14
Status:fixed» active

Sorry to stir up any trouble, but the problem is not fixed. I went and checked my php.ini, and the max file upload size is set at 2M- much larger than any of the files I've tried. I thought that might be a problem before I originally posted, and I just double checked now. I also checked the max upload size as set in the image module (2048 kb).

I tried uploading a file larger than the 2M limit, a large PNG. I recieved the message "The selected file C:\yaoikitten\files could not be copied.
Your Image", which is a very different error message. I know that that folder is writeable by all the processes, as the image import module works no problem. Something else is at work here. Unfortunately, I'm just learning Drupal still and I'm not ready to wade into debugging modules myself yet, but I can provide any info you need. For reference, image nodes (created via import) seem to work perfectly; the only thing broken is the normal upload mechanism.

#13

teyoo - April 27, 2007 - 07:45
Version:5.x-1.0» 5.x-1.x-dev

Uploaded file is not a valid image. Only JPG, PNG and GIF files are allowed.

#14

drewish - June 12, 2007 - 05:56
Status:active» fixed

Charlie Sibbach, you need to ensure that you GD has PNG support enabled.

teyoo, that's not a helpful error message.

#15

Anonymous - June 26, 2007 - 06:18
Status:fixed» closed

#16

nbilyk - October 27, 2007 - 18:30

I'm also having this issue. I know I have write access, the images I'm testing with should work fine (30-60K, jpg).
I'm running IIS, tested with 5 and 6. The latest dev version of this Image module, and the latest version of Drupal.

"Uploaded file is not a valid image. Only JPG, PNG and GIF files are allowed."

Good luck!

#17

nbilyk - October 27, 2007 - 19:18

My problem was solved when I upgraded php from 5.2.4 to 5.2.5 It was an issue with the windows\temp directory not allowing php to access temp files.

#18

Damjan Dvorsek - July 8, 2008 - 21:20

#19

Damjan Dvorsek - July 8, 2008 - 21:20

Is this related to php version or can be fix by giving proper permissions to the temp directory? What are then the proper permissions?

#20

abdraha - September 14, 2008 - 03:19

hi,
Here are my setting :

OS = Window XP
IIS = 5.1
Drupal = 5.1
PHP = 5.1.1

I also have this issue , what i do is :

1) change c:\windows\temp , i gave permission everyone = full control ..

it solved the problem .. but uhmmm ..security iissue ..???

#21

fatlast - September 28, 2008 - 10:12
Version:5.x-1.x-dev» 6.x-1.0-alpha3

heh, guys i didnt solve this problen yet..... i changed permission in C:\windows\temp but it didn't help me...
i still have this problem and i don't know what i need to do

 
 

Drupal is a registered trademark of Dries Buytaert.