Drupal – The selected file… could not be uploaded. Only JPEG, PNG and GIF images are allowed

I’m using Drupal 6.13, I tried to change the logo for the admin template and got this error message. A little bit of digging turned up a comment made by zbricoleur  on the Drupal.org site where he provides a working solution.

In /includes/image.inc, change line 117 from:

  if (!is_file($file)) {

to:

  if (!is_file($file) && !is_uploaded_file($file)) {

That line above works nicely, however next up you might see the error:

The selected file  could not be copied, because no file by that name exists. Please check that you supplied the correct filename.

To get around that problem do this:

Administer/File-System

You might find it under the 'Site configuration' heading and then File System.

There you will see a box that has: Temporary Directory

c:\windows\temp and change it to the same as the line above it which will probably be

sites/default/files

Save configuration and you're good to go.

:)

PS. Nobody leaves a comment if I help them, please let me know if this solution worked for you…

Related posts:

  1. Access denied – Drupal 6.x
  2. Site off-line The site is currently not available due to technical problems. Please try again later. Thank you for your understanding. (SOLVED!)
  3. How to take Ownership of a Drive, Folder or File in Windows 7
  4. Beginning Drupal
  5. Invalid argument supplied for foreach in template.php
  6. Windows 7 file copy and Internet slow – solved
  7. IIS and Drupal – Enable Clean URL’s


5 Comments

  1. Comments  tracedinchalk   |  Friday, 19 February 2010 at 5:01 pm

    I was getting the same error when uploading files.

    Changed the tmp directory to reside inside of the files folder and it resolved the error.

    Thanks for posting this.

    Cheers!

  2. Comments  Simon Nicol   |  Friday, 19 February 2010 at 5:06 pm

    A good tip there, thanks for adding your experience (it will be added to our own – resistence is futile) – lol

    :)

    Simon

  3. Comments  Helen   |  Friday, 24 September 2010 at 8:05 pm

    Thank you for the tip. I was experiencing the same problem and your solution resolved it.

  4. Comments  marc   |  Friday, 26 November 2010 at 3:31 am

    Thanks! I needed that exact information…worked like a charm.

  5. Comments  Allison Wong   |  Saturday, 12 February 2011 at 1:06 am

    Thank you for this! Saved me hours of searching.

Leave a Reply