"Changing this location after the site has been in use will cause problems so only change this setting on an existing site if you know what you are doing"
*blush*... *cough*... So, suppose some foolish person, in the wee hours while attempting to sort out the reason for an image url looking a wee bit strange, ie "www.example.com/site/example.com/files/images/image.jpg", happens to change, in a mopment of complete abandon, the file system settings from 'sites/example.com/files' to 'files'? How would such a foolish person actually repair said damage? I, er... the person did set file system path back to its correct path, and that sorted out some of the issues, but, the image path will not sort itself out, when I try to set it to its correct path I get "The directory does not exist", even though it does...
help? Thanks.

Comments

gpk’s picture

I get "The directory does not exist"

Which directory?

If you changed the setting straight back then I wouldn't expect there to be permanent damage, tho' I don't know exactly how the image module interacts with this setting. The problem with change the setting for a live site is that the uploads table (I think) stores not only filenames but also file paths - hence things can get out of sync.

gpk
----
www.alexoria.co.uk

kpm’s picture

The situation is that the image directory appears as set to "sites/example.com/images" when it should simply be "images". This setting is supposed to be a subdirectory of "sites/example.com/files" file system setting. Drupal rightly claims the directory does not exist, but when I change it to "images" which does exist, is owned by the web server and has 777 permissions, Drupal continues stating that the directory does not exist. The problem is that when I attempt to change the setting from "sites/example.com/images" to "images", I am greeted with the error:

    * The directory does not exist.
    * The settings have not been saved because of the errors.

I even attempted to create the images directory with proper permissions etc in the same location that Drupal images setting remains at, even after trying to change it to 'images', but the "The directory does not exist" error continues to appear.
A "The directory does not exist" error also appears on the top of the "www.example.com/node" page and on the create content pages for blog, image, and video. I imagine there is a setting or two (hopefully not hundreds) that I will need to manually edit directly in the database, Drupal simply will not change that setting with the buttons provided. I just have to figure out where and what that is I need to change. I have found the "file_directory_path" variable in the variables table, but I can't seem to find the image path to change it manually.

cog.rusty’s picture

There should be a variable in the 'variable' table, image_default_path = s:6:"images";

Also, the paths stored in the 'files' table are relative to Drupal's base path, and not relative to files_directory_path.

Maybe that variable was lost during an image module update or something else (I have noticed at least 3 modules calling themselves 'image' at the admin page). Try to insert the variable.

----------- Edited:

Any info in /admin/logs/watchdog about who/what is causing the "directory does not exist" error message for visitors? This isn't something which happens usually with missing images.

kpm’s picture

In my variable table, the image_default_path is s:28:"sites/examle.com/images";
I changed it to your suggestion but the bad behavoiur continued so I reverted back to origianl value..

cog.rusty’s picture

It should be relative to your Files setting. Anyway. moving on...

It is possible that the error message is not caused by that particular setting. I assume there were no details in your watchdog about what directory did not exist. A grep shows that:

- The strings "The" "directory" "does not exist." do not exist in any line in image module, only in core, in includes/file.inc
See: http://api.drupal.org/api/function/file_check_directory/5

if ($form_item) {
  form_set_error($form_item, t('The directory %directory does not exist.', array('%directory' => $directory)));
}

- Another grep in some modules related to image module shows that the function file_check_directory() is called in the following:

./image/image.module-  $image_path = file_create_path(variable_get('image_default_path', 'images'));
./image/image.module-  $temp_path = rtrim($image_path, '/') .'/temp';
./image/image.module-
./image/image.module:  if (!file_check_directory($image_path, FILE_CREATE_DIRECTORY, 'image_default_path')) {
./image/image.module-    return false;
./image/image.module-  }
./image/image.module:  if (!file_check_directory($temp_path, FILE_CREATE_DIRECTORY, 'image_default_path')) {
./image/image.module-    return false;
./image/image.module-  }
./image/image.module-

and

./flash_gallery/flash_gallery.module-function flash_gallery_check_dirs() {
./flash_gallery/flash_gallery.module-  $path = flash_gallery_image_path() .'/flash';
./flash_gallery/flash_gallery.module-  $store_path = $path .'/thumbs';
./flash_gallery/flash_gallery.module:  if (!file_check_directory($path, FILE_CREATE_DIRECTORY)) {
./flash_gallery/flash_gallery.module-    return FALSE;
./flash_gallery/flash_gallery.module-  }
./flash_gallery/flash_gallery.module:  if (!file_check_directory($store_path, FILE_CREATE_DIRECTORY)) {
./flash_gallery/flash_gallery.module-    return FALSE;
./flash_gallery/flash_gallery.module-  }
./flash_gallery/flash_gallery.module-  return TRUE;

So, it could refer to your temp path or to another module.

kpm’s picture

Not sure how any of this caused the image path to refuse to update, but after setting it right in the database and then changing the temp path to /tmp rather than tmp (I had a tmp directory in both the root of the www server directory and the Drupal root directory), and Drupal was not reporting it as missing or protected or anything. Well, it all seems to have sorted itself out now with that slash.
Thanks.

sstacks’s picture

I had the same problem after installing and then deleting the audio module.

Somehow, my temp path in the file system settings got changed but changing it back to /tmp allowed me to correct the image upload path.

Best,
Shane

minnow’s picture

I had the same problem. To resolve:

1. change image_default_path in "variable" to the correct value
2. disable cache
3. access the page and see (should be correct now)
4. re-enable cache

Note: after step 1, I look "cache" table and see "image_default_path" still has the old value.

cog.rusty’s picture

"Knowing what you are doing" usually means knowing

- the image path reported as wrong in the error message.
- the image path which you have entered for the image in the content.
- your current 'files' setting
- your 'images' path setting
- where your 'files' directory and your 'images' subdirectory really are (the ones containing the files).
- "public" or "private" download method?
- the path stored in the 'files' table in the database (if applicable, depending on which module you are using for uploading)

To fix it, just make these things consistent between them. This is the only thing I can say with the available information.

kpm’s picture

unfortunately, I thought I did know what I was doing in my sleep deprived state... I do remember reading that statement a year ago or so when I first started with Drupal and thinking about directory structures with in Drupal sites. Then, as mentioned, I just had a cringe at the site of the urls created within multisite setups for images and attachments etc, and completely forgot about it and "knew" where I had to go to "fix" what I saw as an error... which it wasn't, and now the site is buggered. I really think that sentence should be moved to the top of the paragraph, be bold and bright red... It is an easy setting to change by mistake.

There is no path reported, the only error is "The directory does not exist" which appears in the image admin settings page for the path, on create pages for Blog, Image, and Video, as well as on the home page.
The current file settings is: sites/example.com/files
The current images path setting is: sites/example.com/images
The files subdirectory is: /www/drupal/sites/example.com/files
The images subdirectory is: /www/drupal/sites/example.com/files/image

The problem is that the images path setting should be 'images' but Drupal will not make the change... Every attempt results in the "The directory does not exist" error and then the change I did made reverts back to sites/example.com/images on a refresh of the browser.

The files table lists the files like so sites/saloonsalon.com/files/images/someImage.jpg

Something else I now notice in the logs, there are many statements like the following for all images: "Derivative images were regenerated for Image Title" (where 'Image Title' is the title of any of the images).

So, I suspect a variable or two will have to be edited directly in the database, I am just hoping someone can point me in the right direction.
Thanks.

gpk’s picture

1. Are we correct in assuming you are using the image module?
2. Looks like your images path setting should be something like sites/example.com/files/images

gpk
----
www.alexoria.co.uk