0

When i set my uploads path to ../ on file system, my files inside the css folder get deleted when i clear the cache. My aim is to be able to upload my files on the root outside drupal installation which is possible so far except the deletion of my files. I tried deleting the content of the .htaccess file that gets created in the root folder but there's no luck.

My directory structure is:

root/

----css

-------menu.css(file that get erased)

----drupal

-------drupal installation

----js

-------javascript

----other HTML files

Thank you

2
  • I'm curious, why do you want your files outside the Drupal folder? Jul 18, 2014 at 7:21
  • Hi Pontus, We have the exiting system we are using, so we just want to add some drupal functionality on top not the rest of it
    – jonazz
    Jul 18, 2014 at 7:56

2 Answers 2

1

What you are doing is dangerous. It opens a security hole in your installation. But that's your problem.

Drupal caches pre-combined css and js files in, respectively:

  • public://css
  • public://js

It's hardcoded, and you can do nothing about it. This means that if you will set public to mean your ../, Drupal will use ../css and ../js for CSS and JS caching purposes - all purposes even cache clear. For performance reasons Drupal does not care if it was this installation that created cache item when you tell it to clear it all. Why should it? Clear is clear after all.

Long story short: Don't set drupal's public:// to anything you don't want Drupal to manage. If you really have to, symlink specific directories, or write custom module to manage such uploads.

5
  • Thanks Molot, It seems there's a lot of things I do not understand about the cache. Does it have anything to do with the deletion of files?
    – jonazz
    Jul 21, 2014 at 10:30
  • @user33470 css and js are file-cached. The files in public://css and public://js are caches.
    – Mołot
    Jul 21, 2014 at 10:32
  • is there a way to changes the caches from public://css say to public://cssx?
    – jonazz
    Jul 21, 2014 at 10:38
  • @user33470 Nope, not really. Not without hacking core, as far as I know. Maybe modules like advagg, ones that provide total alternative to Core cache provide such configuration, but I doubt if they would prevent core css cache clear, even if you are not using it.
    – Mołot
    Jul 21, 2014 at 10:50
  • yep, as you said the advagg module is not doing the trick. Thanks a lot anyway
    – jonazz
    Jul 21, 2014 at 11:02
0

Yes as @Molot suggested you can create symlinks. If you want to upload files outside the drupal directory you can create symlink to that outside directory in /sites/default/files, and in apache configuration you can enable FollowSymLinks to allow the follow symlinks outside the drupal directory. To enable FollowSymLinks you can do change something like this in your apache config file.

<Directory /path/to/your/drupal/root>
  Options +FollowSymlinks
  AllowOverride All
</Directory>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.