Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
i am writing my own cck field. I am stuck with the following problem:
I want to save the files outside the www root folder so i want to alter the file path and set a custom oath (/var/files). Any tips if that is possible?
Thank you.
Comments
Comment #1
KarenS CreditAttribution: KarenS commentedCCK does nothing with files. Maybe you want to ask in filefield.
Comment #2
quicksketchThis is not possible generally speaking. You could make a symlink on your server from a directory within the files directory to another location though, then lock it down through .htaccess. However Drupal will have a hard time trying to display the files if they're not accessible under the files directory. Private downloads may also accomplish what you want, but I generally discourage their use because enabling private files has severe performance penalties.
Comment #3
marcoka CreditAttribution: marcoka commentedNot possible is bad, because as you said private files has a performance issues. In my case i display 90 Thumbnails and that will be a bootstrap overkill with private.
I thought about the htaccess method and read a lot of posts on drupal.org about it. One problem with that is an imagecache bug that makes the pictures accessibe over non clean urls like ?q=/mypath/foo/image.jpg, even if you use a RewriteRule.
Thats why i wanted to make my own private cck field, my own small private imagecache with selective access permissions (so i can save all thumbs in public, causing no bootstraps) and route all other images through a custom accesscheck.php to make it high-performance.
But if thats not possible i can crush this conceptual idea.
Thank you for the infos.
Comment #4
marcoka CreditAttribution: marcoka commentedOk it its possible. Today i hacked the upload module for testing purposes.
If you load global $conf and the set file_downloads, file_directory_path on your path its working. Disadvantage is that you need to rewrite the whole thing/output etc on these paths because drupal will still get sites/default/files and look for the file there. Another disadvantage is that every module working with uploads, wont work anymore.
Comment #5
quicksketchI suggest giving http://drupal.org/project/filefield_private a shot. Otherwise I think this is generally out of scope for FileField, since it's mostly a server configuration problem.
Comment #7
marcoka CreditAttribution: marcoka commentedthanks quicksketch.
i already took a look into the code of filefield_private. thats were i got the idea from with modifying global $conf.
i took a different way now, forked imagecache with some pacthes postet in the issue queue by EugenMayer, secured the whole filefield folder with an .htaccess and wrote an imagecache protection module based on these patches. now i can protect every image i want, make it private without using the slow private mode