when I first set up Drupal and the image module it worked really well. I was able to upload without a problem. However, I have been adding modules and fiddling around, and now it doesn't work. When I submit an image node, it churns away for a bit and then pops back an error saying
"The selected file /hermes/web05/b650/pow.hongpong/drupal-test/htdocs/files could not be copied.". Oddly, it creates a zero-length file named either 'file', 'file_1' file_2 etc in the proper ultimate image destination folder each time i try, sequentially. i've tried clearing these but they come back.

At the moment I have these modules active:

aggregator, blog, collapsiblock, comment, devel, devel_node_access, embedfilter, help, image, image_attach, image_gallery, img_assist, jstools, menu, page, panels, path, poll, profile, service_links, statistics, story, tagadelic, taxonomy, throttle, upload, video, video_customfields, video_image, video_multidownload, video_optmetadata, video_params, video_upload, views, views_theme_wizard, and views_ui .

I have hosting on PowWeb (shared box), and I suspect this might be a problem with permissions, but I made sure that /files has 777 and /files/images, /files/images/temp as well. I thought maybe there was some htaccess URL rewrite glitch since I activated that (with standard file) after I got image upload working, but i can't find anything related to that in htaccess. Possibly i should try changing the group owner to the web server, but 777 ought not to make that a problem. It is running on a subdomain.

So my theory is that the argument for locating where to move the image into the permanent folder is missing some kind of argument, or i garbled it up somewhere, or else one of the other image modules mucked it up. Thanks for any help or suggestions!

Comments

Alison-1’s picture

I've set the permissions to the files directory to 777 and I'm still getting the "files could not be copied" error when I try to upload images.

Originally, the images would upload, but wouldn't display (But the people who host my site fixed this for me by renaming the htaccess file, which then broke again but that's another story.) Since then I have installed some new modules and now the images just don't upload at all.
I'd really appreciate some help. The hosting guys are being ever so helpful, but it seems to be more of a Drupal issue than a server problem.

So, thanks in advance for suggestions!

jurgen.lists@drupal.org’s picture

Me too... Same problem. Very strange. Has nothing to do with ownership of the files directory, that I found out already. But nothing else so far...

hongpong’s picture

Funny thing is that I got a message on this this morning, and i only fixed it last night at 1:30 am! So last night i got it working, after quitting working on the problem for weeks. I decided to blitz the situation and switch my production site to Drupal (http://www.hongpong.com/ ), in the hopes that it was some anomalous permission error that might be limited to my hosting company's weirdness. (and a fresh file install might duck the problem)

however i was quite sad after i put fresh copies into my main directory, created new 'files' and images folders with 775 and 777 permissions (tried both for each) and same damn error happened.

i also had the minimal set of modules - far fewer than my previous setup above, which meant it was less likely to be a simple module conflict.

then i took a hunch (like Orson Welles in 'touch of evil', i go on intuition) changed a couple settings in the 'content type' controls under 'settings', here:
admin/settings/content-types/image
I disabled "attach images" and "attachments" for image nodes and saved configuration.

then i went back to the 'create image node' page. interestingly, the actual 'browse to image' box on the form actually moved around (from *above* the category box to *Below* it) - and i sensed i might have nailed it. so i uploaded that remarkable image of the Coup in front of the exploding world trade center - and it worked! here:
http://www.hongpong.com/node/789

so i think the lesson is that image nodes should not have more attachable images and/or attachments. i may have made other changes that fixed it, but i'm pretty sure this is what did it.

(note: i am experimenting now to see which one it is - and it appears that *only* allowing images causes the image-browse box to move around - and therein probably lies the problem)

Steel Rat’s picture

And, without all the commentary ;), disabling the image attach for image nodes fixed it.

Odd though that I had been using this for weeks without making any settings changes, and suddenly it stops working.

Steel Rat
Drupal Site: RPGMapShare.com

Metusela’s picture

Thanks a lot guys!!! Had the same problem, but diabling attachents for images fixed it.

=D
nimazuk’s picture

Thanks!
disabling the image attach worked for me!

Nima

krzysiek@palikowski.vel.pl’s picture

great fix :) and great style for a comment too

Anonymous’s picture

Thanks. This one has been a burr in my show for months. Thanks again...===
Doug Ouverson
hear | see | say | do | teach

Johnl-2’s picture

I had the "files could not be copied" problem just a couple days ago.

Turns out php defaults to limit uploads to 2M and my picture was 2.3M.
So I just went into the php.ini file and changed upload_max_filesize to 8M.

I haven't had anymore issues.

I hope this works for you guys.

elipticill’s picture

I have followed these configuration explanations strictly on a new Drupal install, but can't seem to get an image to upload to my chosen directory (drupal/files/pictures/temp) via the image module. Database updates proceed without error following module configuration, but there doesn't seem to be a table for images in my site's database. I am not sure whether there is supposed to a table for these, but it would make sense that there might be.

Is there somewhere else I might troubleshoot?

Thanks in advance.

hanaichigo’s picture

and couldn't fix it, came to this page, and finally fixed the problem, following the advice by HongPong.
Thank you very much for your post HongPong, this community is really great!!

ViTok’s picture

Thank you HongPong for your post!

erikhanson’s picture

Thanks a ton. This was driving me nuts. The fix with less text.

Administer > Content Types > Image

Then disable both "Attach Images" and "Attachment"

rick hood’s picture

Same exact thing happened with me. New Drupal 5 install, and was working fine then all of a sudden got "files could not be copied".

Disabling attach images to image content type worked for me to. But why?

One thing: I had the "Image enhanced scaling" module enabled, and later disabled it. Same with "Thickbox". I am not sure if disabling one of these started the problem or not.

Squirrelly’s picture

Yes, I was getting this error on a new Drupal 5 install after it had been working for a while. I just went to Administer > Content Types > Image and only needed to disable "Attach Images" to fix it (I left the regular file attachment setting enabled).

Thanks!

TimDev’s picture

The selected file /tmp/tmp_... copied...

I've been busy about 2 days with this problem, I tried everything above but still not working:(

Maybe it has something to do that I made some folders like /images and /pictures and /temp writable.

Please can somone help me?

dpandey’s picture

I host with PowWeb was getting the same problem (The selected file /hermes/.../files could not be copied).

CGI Error Logs was dumping the following message every time I tried uploading an image.

PHP Warning:  File upload error - unable to create a temporary file in Unknown on line 0

A few searches on Google provided the answer. The default php.ini provided by PowWeb comments out 'upload_tmp_dir'.

; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
; upload_tmp_dir =

All I had to do was to set 'upload_tmp_dir' to "/tmp" and everything was fine.

; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
 upload_tmp_dir = "/tmp"

I still believe this is a hack and the service provider should fix it.

chrislynch’s picture

I'm having the same problem - spontaneous combustion of my ability to upload using the image module.

Interestingly, I had only recently activated the upload module (which might have something to do with it?) on one one of two sites that is now failing. On both, attachments still work on other content types.

I have deactivated attachments on images as instructed, and also tried the various fixes to the php.ini using ini_set to no avail.

I've popped a note into my host to see if anything has changed recently in terms of PHP configuration.

chrislynch’s picture

I've fixed this on my host, Servage, after trying several options.

The fix for me at least seemed to require ...

  1. Matching the name of my local tempoary directory (the one that Drupal points to) to the name of the directory that PHP reports as using for temporary uploads if you run a phpinfo()
  2. Deactivating safe mode
  3. Updating the .htaccess file to follow symlinks

Not much science to this fix, just a lot trial and error and (luckily!) being able to compare and contrast the two or three installations of Drupal I have with Servage against what their automatic installer does.

Hope this helps someone else out - was a bit of a nightmare to lose file uploading from my site for a few days!

joyfulchicken’s picture

I'm on Servage too, and file upload isn't working. phpinfo() reports /upload_tmp as the upload_tmp_dir, but when I try to set it as the temporary directory, I get this message:

Security warning: Couldn't write .htaccess file. Please create a .htaccess file in your /upload_tmp directory which contains the following lines:
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
Options None
Options +FollowSymLinks

I don't know what to do next because I don't have access to the /upload_tmp directory.

Can you tell me how you fixed yours?

Thanks.

Jim@drupal.be’s picture

Perhaps there is a difference in drupal 5 but I can only disable the 'allow attachments' setting under content types. the adding images setting is not availeble.

I can upload images without any problem. The error occures when changing the image title or description.

UPDATE: solved by using this patch http://drupal.org/node/124474

There are no stupid questions. Only stupid anwsers.

dimiduj’s picture

I had the same problem on servage...
Here is a settings who works for me ....

for the temp you must use the "upload_tmp" directory with chmod 777, and the upload_tmp must be a brother of the file directory (as expected that your directory for upload is "file) in the arboresence tree folder not a child... (am I clear ??? => not :) ) :

root_dir
|
_____
| |
files upload_tmp

note that these settings are for a single site installation ie : the files dir isnt in the site dir ...

suit4’s picture

Me, too, had this error.

Before this error, I used to keep the upload tmp dir in the files dir, and it work for many file uploads.

From one day to another, this stopped working without anybody having changed anything in Drupal or on the server.
So how can that be? Any ideas and hints are really appreciated!

Anyway, dimiduj, your fix work for me, so many thanks.

---

Ok, next I get an error like:
Could not create destination .... from imagecache.

File and folder permissions are all 0777, so there should be no problem in creating files.
Can this be an problem of somehow broken jpegs?

suit4’s picture

This problem keeps bugging me on different systems.

I still agree to dimiduj, that it is in deed a good idea to have the upload temp directory in the root directory.
Just yesterday, I again had an issue with an image not being created. I checked the permissions over and over again, and came to the point, that it is not enough to have the permissions correct, but also the user and group for the folder must be ok, otherwise there may be problems with safe_mode stuff.

this is my current file and permission structure:

structure
root_dir
--files                     root:root              0777
----imagecache              wwwrun:www             0777
------mythumb               wwwrun:www             0777
--------files               wwwrun:www             0777
---------- xyz.jpg          wwwrun:www             0777
---------- ...          
--upload_tmp                root:root              0777
---------- ...          

PHP safe_mode is switched off.
If files or upload_tmp is owned by wwwrun, this doesn't work.
If one of the folders imagecahce or below are owned by root, this again doesn't work.

If someone can verify this, maybe we can put together the final solution from all partly solutions ... someday.
And if there is a final solution, it would be nice to have an integrated check in the imagecache module, won't it?

jonahan’s picture

My problem with this turned out to be a permission thing. I went into the main Drupal directory and ran this command:

chmod -R 777 files

I was then able to upload images :)

Hope this helps!

-------
http://jonahan.com

Anonymous’s picture

Also make sure that files/images/temp is set correctly, the image module installs that directory as 775, not 777.

VVDFractie’s picture

I had the same problem. No image uploads possible. Drupal is hosted at a provider with a webbased administrator tool. With this tool I saw a temp directory under files/images but with different UID/GID I deleted the file and created a new file with help of this tool. I this way it had the same UID/GID as the script of Drupal.

tjholowaychuk’s picture

Just went to the Image section in the admin and all the fields were empty where there normally would be thumbnail, preview etc that are not editable so i put them back in now it doesnt spit out the cannot be copied error

unitec’s picture

I had the same problem.
There are two image modules, there is also one for CCK.
I disabled the CCK image module and now it's working fine.

Used BMW 323 i

jmlavarenne’s picture

Same problem. Used my ftp client (filezilla) to delete both temp and tmp folders from the files/images directory and created those folders anew with permission 777.

sgwood’s picture

Hi all,

i too had the "File upload error. Could not move uploaded file." error.
I'm using the the IMCE module.

The "Temporary directory:"-field was incorrectly set on the "File system" page
i.e.
Administer › Site configuration > File system

As I am developing under windows using Wampserver.com the "Temporary directory"
was set to "C:\wamp\tmp"
When I imported the DB using phpMyAdmin to my apache server the temporary path was still
set to the windows path.

The "Temporary directory:"-field is now set "tmp" on the apache hosting.
I created the "tmp" folder in Drupals root folder and 777ed it.

hope that helps others.

justbradford’s picture

That worked for me exactly! Was getting a "couldn't move file" error when trying to upload an attached image. Disabling Attached Images was not an option, but it turned out that the temp directory in Administer › Site configuration > File system was still set to a local machine directory...so fixed that and all is well!

derridaisdead’s picture

Experienced a similar problem with same error notification.
The cause was quite something different though.

So if all this didn't work out for you, you might consider checking if the GD library for PHP is installed.

You can see this through Administer > Reports > Status report.

Installing this library and restarting the server did the trick for me.

Cheers.

Krummrey’s picture

it was the temporary files directory that wasn't set right. See if that does the trick for you.

rastin71’s picture

Just had a frustrating 4 hours of searching the usual suspects with no luck.......

I'm using a separate volume for web content that shares space with my backups, DB upgrade I did broke mysqldump, which broke my backup routine, which no longer calls the last step, which is cleanup....

So my volume was 100% full and like the message said "Files could not be copied."

ruyguy’s picture

I got this same error when I tried to upload a pdf with a full disc quota on the server. Solution: increase the disc quota. :)