Hello! I have my site running with drupal 6.8 and Imagecache 6.x-2.0-beta8 with Imagefield 6.x-3.0-alpha4 and it was working great!!! it had no permission issues... and now it shows this warning all the time:
warning: mkdir() [function.mkdir]: File exists in /var/www/html/ruta504/sites/default/modules/imagecache/imagecache.module on line 511.

Can anyone help me??? thanks...



pspdrupal’s picture

I'm having the same issue. Previous uploaded images work fine but none of the new ones I upload appear and I get the same error message.

pspdrupal’s picture

I found the problem. The permissions were not set correctly in the folder: sites/default/files/imagecache. I changed them and the error is gone.

lizbethalml’s picture

Status: Closed (fixed) » Active

yeah so did I!!!!!! My partner had copied the folders with the name of the imagecaches directly in ftp so... we flushed the presets and everything worked! thank God!!!

lizbethalml’s picture

Status: Active » Closed (fixed)
rosquilla’s picture

Status: Active » Closed (fixed)


could you please tell me which are the correct permissions to set? Thanks a lot! Best regards!

vertazzar’s picture

they must be 777

rainbreaw’s picture

If resetting the permissions does not work for you -- I found that editing the imagecache.module file on line 555 to say this:

if (!file_exists ( $dir )) { mkdir($dir); }
else if (!file_check_directory($dir, FILE_CREATE_DIRECTORY) && !mkdir($dir, 0775, TRUE))

instead of just

if (!file_check_directory($dir, FILE_CREATE_DIRECTORY) && !mkdir($dir, 0775, TRUE))

solves the problem. It just re-enforces the check to see if the directory imagecache is trying to make already exists.

I hate the idea of editing a module, and am not sure if this is the best solution, but changing permissions didn't solve the issue for me and this edit did.

soapmode’s picture

I'm having the same problem with imagecache, getting the error message 'warning: mkdir() [function.mkdir]: File exists in...' and images not displaying. I'm using it with Ubercart, of which it's a core component. I have no idea what's wrong, but it seems clear to me that Imagecache is a source of constant problems. I also tried editing line 555 of the module, as described above, but no dice. Please help!

Additional: I've set the files folder, plus all related Imagecache folders to 777. I've also flushed preset images through Drupal. I have clean URLs enabled. Still nothing.

Edit: Setting files/ to 777 with owner and group recursion ticked seems to have fixed this.

cpapaya’s picture

I am having similiar problem. Old files are showing. But imagecache is creating a second folder. files/files
I changed the code of imagecache_module line 555 & it did not work
New folder is still created & new pictures are not seen
how do I fix this

kip stanning’s picture

Title: warning: mkdir() [function.mkdir]: File exists in /var/www/html/rmysite/sites/default/modules/imagecache/imagecache.module » similar problem solved in unexpected manner

after migrating a site pictures of imagecache directories were shown but new pictures were not saved in imagecache directories and - consequently - didn t show up.

error messages were something like "unllink" pointing to a line in file.inc and a message containing mkdir.function (or something like that) pointing to line 555 in imagecache module (file exists ...).

i discovered by chance that new presets worked perfectly and didn t bother about this malfunction any more but just added new presets and enabled them in views and user profile pages.

thx for your discussion folks. hope somebody can make use of my solution in similar situations.

greetings from vienna forest
kip / karl staudinger

tomchapin’s picture

I had this same problem and at first I couldn't figure it out (I had the permissions for sites/default/files/ all set to 0777 and everything seemed correct), until I remembered that I had changed the default location for uploaded files when I had initially set up drupal.

So yeah. Go to /admin/settings/file-system and check to see what your actual file path is for uploads and make sure that it exists and has the proper permissions. You will also need to set permissions to 0777 for any sub-folders (such as "imagecache" and "imagefield_thumbs").

I hope this helps.

wwwoliondorcom’s picture

Ubercart shop products pictures disapeared after imagecache update


Any idea why Ubercart products pictures have disapeared after Image cache update ?

Thanks for your help.

bstoppel’s picture

I applied the same patch that rain indicated in comment #7. It worked for me.

JAScarb’s picture

This occurred to me today, out of the blue. I notice the owner of the problem files isn't the same as the owner of all the successful files. I've raised a support issue with my host and will keep you posted. Directories 777 didn't fix, but I haven't done the module change yet, it seems like a good plan to work out what's changed since yesterday.

JAScarb’s picture

Oh, I'm also getting http error 0 occurred /filefield/aha/product/field_image_cache/1 . There is no aha subdirectory of filefield, which is 755. Perhaps it wants that to be 775 at least.

Response does seem very slow from the site, so perhaps this is a different (performance, attack) issue.

christefano’s picture

Title: similar problem solved in unexpected manner » warning: mkdir() [function.mkdir]: File exists in /var/www/html/rmysite/sites/default/modules/imagecache/imagecache.module

The solution for this is explained at Troubleshooting imagecache migration handbook page.

marcus7777’s picture

Thanks (@rainbreaw) that was a big help :0)
I needed to add ("imagecache/a/b/c") directories to the files folder so:

if (!file_exists ( $dir )) { mkdir($dir,0775,true ); }
else if (!file_check_directory($dir, FILE_CREATE_DIRECTORY) && !mkdir($dir, 0775, TRUE)) 

Thanks again.

gultig’s picture

Thank you. Changing permissions on all sub-folders for the actual upload file path.
Worked for me.

junkbox’s picture

This error will also popup if the path to the public/files folder can not be found. In my case I use an external drive for my public files and cache folders. It had become unplugged and was obviously not available to the system. Likewise if you're using an external for these and it becomes unmounted you'd get that error. Just a heads up.

ufku’s picture

This is not a file/directory permission issue.
It happens on multiple concurrent requests that create imagecache images in the same folder. It only happens once when a new folder is created. That's why people think it is fixed after it's first occurrence.
While request-1 is creating the folder, request-2 checks its existence and also tries to create it because it is missing. However, request-2's attempt (mkdir) fails because the folder is already created by request-1 in the meantime.

Makku01’s picture

and how can one deal with this issue?

mikeytown2’s picture

Title: warning: mkdir() [function.mkdir]: File exists in /var/www/html/rmysite/sites/default/modules/imagecache/imagecache.module » Warning: mkdir(): File exists in imagecache_build_derivative()
Version: 6.x-2.0-beta8 » 6.x-2.x-dev
Category: support » bug
Status: Closed (fixed) » Needs review
642 bytes

line 604 of sites/all/modules/imagecache/imagecache.module

tic2000’s picture

I confirm the issue in 20.
I'm uploading images using swfupload in a form. The directory where the images are uploaded is created when displaying the form. On submition for each image uploaded a node i created and when done I redirect to a view with a list of thumbnails. No matter if I upload 2 images or 100 only one thumbnail will not be displayed and I have 3 watchdog errors. A php from mkdir() and 2 from imagecache for not being able to create the directory and not being able to create the image.

If I use the solution in 22 the image is created, but the php error still appears in watchdog. I moved !is_dir($dir) between file_check_directory() and mkdir() and the issue is fixed.

christefano’s picture

@tic2000: Thanks for the tip! Can you reroll the patch at #22 with your change?