Some Technical Details

  • Drupal Version: 5.3
  • MySQL database Version: 5.0.24a
  • PHP Version: 5.2.3
  • Unicode library: PHP Mbstring Extension
  • Web server: Apache/2.0.61 (Unix) PHP/4.4.7 mod_ssl/2.0.61 OpenSSL/0.9.7e mod_fastcgi/2.4.2 DAV/2 SVN/1.4.2
  • Image Module Version: 1.209.2.48 2007/09/29 05:19:40
  • ImageMagick Version: 6.2.4 09/16/06 Q16

Drupal Configuration Details

  • File system set to "/home/user/files/example.com"
  • Temporary directory set to "/home/user/files/example.com/tmp"
  • Download method set to "Private"
  • Default image path set to "images", which should result in "/home/user/files/example.com/images"
  • These other directories also exist:
    • /home/user/files/example.com/images/import
    • /home/user/files/example.com/images/temp
    • /home/user/files/example.com/tmp

Noticed Behavior

  • When I first installed the site fresh, the following directories magically appeared:
    • /home/user/example.com/files/tmp
    • /home/user/example.com/files/images
    • /home/user/example.com/files/images/import
    • /home/user/example.com/files/images/temp

    I think that's all of them (plus or minus one or two).... I'm not sure, I'm trying to remember, because I have since deleted the directories in an effort for troubleshooting.

  • When I go to import an image, the following happens:
    • Image gets moved from "/home/user/files/example.com/images/import" to "/home/user/files/example.com/images/temp"
    • Image node is created and Image Import page (admin/content/image_import) says "The selected file /home/.watson/user/example.com could not be copied."
    • The original image, which was moved to "/home/user/files/example.com/images/temp" has not moved, it is still in this directory.
    • No image thumbnails have been created ANYWHERE.

Troubleshooting Steps

  • Disabled the Image Attach feature per the suggestion of http://drupal.org/node/84405... Didn't help.
  • Tried tinkering around with different file names (spaces, no spaces, length, etc), extensions (jpg vs JPG), and sizes (200KB vs 2MB - thought ...maybe... this could have had something to do with it originally because PHP is set to 4MB limit) and this didn't make any difference.
  • Reinstalled entire Drupal installation to see if it was something wonky from when I switched from public to private. This reinstallation was an entirely clean install. I had completely deleted the database, reinstalled Drupal, reconfigured the Drupal install step-by-step, reconfigured the modules, and tried to again import images. Didn't help.
  • Haven't upgraded to a newer version of Drupal yet because I have a module I'm using for something completely unrelated that doesn't yet support an upgrade.

Any help would be greatly appreciated.

CommentFileSizeAuthor
#24 image_file-exists_243895.patch2.01 KBHetta
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

RobertNelsonVance’s picture

Priority: Critical » Normal

Opps.... I don't think this should be marked "critical". Changing.

RobertNelsonVance’s picture

Further note...

My webhost has your domain setup in your home directory under a directory labeled the domain name.... let's say "/home/user/example.com", which is where your Drupal site would typically reside (or at least mine does).

Now.... this error message says "The selected file ... could not be copied"

I am wondering.... could it be possible that Drupal is looking for a file instead of a folder.... since the folder name is something like "/home/user/example.com/..."?

Could this be botching things up?

dman’s picture

permissions on /files and /files/images are as they need to be? (Writable by the webserver)
Visiting your admin site status, filesystems settings and admin image settings didn't throw up any warnings?

Hetta’s picture

If you're using imagemagick, have you moved imagemagick.inc to /includes/ ?

RobertNelsonVance’s picture

@Hetta - I do NOT believe I have moved anything as such. But in checking.... "image.imagemagick.inc" IS in "example.com/includes/". Is this bad? If so, where should it be?

@dman - ALL permissions for anything relating to this issue have been set to 777.... the images I was importing and ALL the directories that are used (the ones mentioned above in my initial topic post). The ONLY Status Report warning I have is about Cron cause I haven't run it yet.

Any thoughts on my #2 comment (http://drupal.org/node/243895#comment-798725)?

Hetta’s picture

Ok, get the latest version of image (5.x-1.7 is current, I believe), and tell us if the problem still exists. Image 1.3 is WAY old.

And a google search for drupal + your error message gave this:
http://drupal.org/node/160671

RobertNelsonVance’s picture

@Hetta - Ok.... downloaded the http://drupal.org/node/222736 copy of the Image module. Moved the old copy to "{Image 20080308}" in my module directory. Unzipped and uploaded the newer version of Image. Didn't solve the problem.

RobertNelsonVance’s picture

Version: 5.x-1.3 » 5.x-1.7

Upgraded module to latest Version didn't solve this issue.

RobertNelsonVance’s picture

Going to attempt Drupal update, will post back with results.

RobertNelsonVance’s picture

Ok.... so, I upgraded to Drupal 5.7 today and made sure ALL the active modules were up-to-date. I also uninstalled and removed from the modules directory ALL of the inactive modules.

The directories mentioned above have not changed. Neither have any other configurations. Just upgraded Drupal and active modules.

ALL previous errors mentioned in this thread no longer exist. However, I am now receiving the following error: "Unable to create scaled Thumbnail image".

I am observing that the original image is moved from "/home/user/files/example.com/images/import" to "/home/user/files/example.com/images". As far as the temp directory, "/home/user/files/example.com/images/temp" remains empty. NO thumbnails have been saved ANYWHERE.

Thoughts?

RobertNelsonVance’s picture

Let me put it this way..... Is there anyone out there who has successfully setup the image module using the private file setup? If so, what configuration did you use? Drupal version, Image module version, directory structure, etc. Thanks.

dman’s picture

Well, I'll say this, you deserve an award for being the most polite, useful, troubleshooter with a problem I've seen here for a while!
Kudos!

However, it's still tricky to guess from here what's up at your end.

Me, I go into the core file.inc and start dumping diagnostics.

Eg, go into /includes/file.inc, find

function file_copy(&$source, $dest = 0, $replace = FILE_EXISTS_RENAME) {

and add something like:

drupal_set_message("Copying '$source' to '$dest' ($replace)");

to see if that func is really receiving an empty filename.

If so, backtrack... could be the file_move right back at image.module:

_image_insert(&$node, $size, $image_path) {
  $original_path = $node->images[IMAGE_ORIGINAL];
  if (file_move($image_path, _image_filename($original_path, $size, FALSE, $node))) {
    // Update the node to reflect the actual filename, it may have been changed
    // if a file of the same name already existed.
    $node->images[$size] = $image_path;

Try a diagnostic dump there

drupal_set_message("inserting image <pre>". print_r($node,1) . "</pre> ... with image path: '$image_path' );

...
etc. etc.

Hetta’s picture

"Is there anyone out there who has successfully setup the image module using the private file setup? If so, what configuration did you use? Drupal version, Image module version, directory structure, etc. Thanks."

I've been using private files on drupal 5 since I switched my site to drupal, in February last year (it went live in September).
That's:
Private files
Drupal 5.1 through 5.7
Image module 5.x-1.(whatever) through 5.x-2-dev (which I currently use)

admin/settings/file-system
File system path:
/home/server/user/drupal/files (this is OUTSIDE of web root, cos I use private files)
Temporary directory:
/tmp
(x) private files

admin/settings/image
Default image path:
images/xx

admin/settings/image_import
Image import path:
/home/server/user/drupal/files/import/

MySQL 5.0.26 (and 5.whatnot on the live server)
PHP 5.2.5 (and 5.whatnot on the live server)
Apache/2.2.3 (and 2.whatnot on the live server)

Adding debugging messages to file.inc sounds like a really good idea.

Hetta’s picture

Oh, and did you remember to move image modules' imagemagick.inc to /includes/?
If you don't have GD installed, and don't move imagemagick's include file, you can't create thumbnails ...

thomas23@drupal.org’s picture

On my site the same error occures after attempt to create "new content image", i.e. create an image node. The error only pops up if I choose imagemagic toolkit; everything is fine with gd2 selected. See below that convert is in the right place.

Messages are:

Unable to create scaled Thumbnail image
The selected file /home/www/drupal could not be copied.

This is version 6-dev. Some more tech infos from drupal's status page:

Drupal 6.4
Image gallery Galleries defined
Image import Import directory sites/noisomepaste.de/files/import/images exists
Image module directories Exists (sites/noisomepaste.de/files/galleries)
Image toolkit The imagemagick toolkit is installed
ImageMagick advanced options ImageMagick image toolkit is selected
Module and theme update status Up to date
MySQL database 5.0.45
PHP 5.2.6
PHP memory limit 125M
PHP register globals Disabled
Web server Apache/2.2.3 (Debian) PHP/5.2.6 mod_ssl/2.2.3 OpenSSL/0.9.8c

$ ls -l /usr/bin/convert
-rwxr-xr-x 1 root root 25881 Jul 3 15:21 /usr/bin/convert

jp.stacey’s picture

Version: 5.x-1.7 » 6.x-1.0-alpha3

We're having the same problems on the site we're currently building (6.x-1.0-alpha3).

I've been sticking var_dump()s into _image_build_derivatives() (the source of the error) and below, and have come up with a couple of pointers.

  • Firstly, we had 5.x tables lying around, prior to an upgrade. This meant that $size['operation'], which should have been "scale" by default, was set to NULL. This breaks the switch/case statement based on this variable. Going to admin/settings/image and just saving the form with the dropdowns all on their default ("Scale image") fixed this.
  • Secondly, GD conversion is failing. image_gd_resize() can be found, but imagecreatefromjpeg cannot. This is because the default Apache/PHP/GD stack does not necessarily include JPEG support.

Diagnosis: firstly, can you convert GIFs? Secondly, run phpinfo() e.g. put a file in your Drupal root called e.g. test.php containing:

phpinfo();

(Remember to delete this file afterwards as it reveals your server config and is therefore a minor security risk.) Now visit e.g. http://example.com/test.php. You should see a table of the details of gd support (which means Drupal doesn't complain), but it won't contain anything about JPEG support.

The solution is to either recompile (or reconfigure) PHP-GD. I'm getting a sysadmin to look at this for us (the server is a slightly esoteric RHEL system running a multi-user developer environment, so it ain't obvious what I should be tweaking).

Any thoughts on where to put the "scale" bug? And should this bug move to core Drupal image.inc rather than this module? It's clear to me that just saying "GD is working on your server" isn't enough of a diagnostic, if JPEG support might not be present. I've had a quick Google and GD-minus-JPEG is fairly common out of the box.

jp.stacey’s picture

I should add that my original error was very similar to the first posters i.e:

"The selected file /usr/local/apache/htdocs/drupal/drupal-6 could not be copied."

As above, that suggests it's trying to copy the Drupal root. Maybe if this is primarily a GD/JPEG issue, then the issue for the image module is to improve the error reporting?

Sivaji_Ganesh_Jojodae’s picture

Project: Image » Node import
Version: 6.x-1.0-alpha3 » 5.x-1.0
Component: image_import » User interface

The following steps solved my problem

1.create a new folder /tmp/files
mkdir /tmp/files

2. change the file permission
chmod 777 /tmp/files

3.Goto url "?q=admin/settings/file-system" set the Temporary directory to "/tmp/files" and click the button save configuration

4.Now goto url ?q=admin/content/node_import you will be able to upload the file

Robrecht Jacques’s picture

Project: Node import » Image
Version: 5.x-1.0 » 6.x-1.0-alpha3
Component: User interface » image_import

Are you sure this is about the node_import module? Moving it back to image_import.

bscoz’s picture

On my end, this seems to have something to do with the image size. Even after changing the import options I cannot upload an image that has a preprocessing size of more than 1.5 mb without getting a "file doesn't exist" error.

I've worked around by just ftping to the import directory and using the batch import page, but just posting this in case it helps resolve the issue.

estim8d’s picture

I ALSO get this error...

barretr’s picture

Version: 6.x-1.0-alpha4 » 6.x-1.0-alpha3
Component: image.module » image_import

permissions on /files and /files/images are as they need to be? (Writable by the webserver)
Fixed the problem for me. Thanks, dman.

sun’s picture

Version: 6.x-1.0-alpha3 » 6.x-1.0-alpha4
Component: image_import » image.module

To summarize:

- Image module should spit out an error message on admin/settings/image, if files, files/images, or files/images/temp is not writable by the webserver.

- The other issue, mentioned in #20, is probably caused by usage of is_file() instead of file_exists() - numerous comments on php.net mention that is_file() tries to loads the entire file into memory on certain platforms.

Hetta’s picture

Status: Needs work » Active
FileSize
2.01 KB

OK, patch attached, fixing that in the three files where it's found in the image folder. Note, after applying the image.imagemagick.inc should be copied to /includes/ again ...

sun’s picture

Version: 6.x-1.0-alpha3 » 6.x-1.0-alpha4
Component: image_import » image.module
Status: Active » Needs work
Hetta’s picture

The current HEAD already does throw an error to admin if files or files/import isn't writable ... dunno about temp, though.

sun’s picture

Status: Active » Needs review

awww... Please do not update previous comments (only to fix grammar or typos).

Setting proper status.

sun’s picture

Status: Needs review » Fixed

Thanks, committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

ohthehugemanatee’s picture

Note for posterity:
I updated from 5.1 to 5.18, and updated all my modules. One of my sites had this exact problem... in the end, going to /admin/settings/image and hitting "reset to defaults" solved the problem.

Francewhoa’s picture

The following worked for me http://drupal.org/node/541872

rajmataj’s picture

Solution might be here if using FileField

stewest’s picture

This worked for me, uncheck "Active Updating" if using FileField
http://drupal.org/node/734680#comment-2807130