I have a Drupal 7 website with an existing file field set to store files in the public folder
(i.e. sites/default/files).

I need to switch this one field so that it stores files in the private folder. Because the field has already been set to public and there are a number of existing files in place - the option to change the settings to private is not available in the user interface. I was wondering if anyone has a way to make this change manually in the database.


3 Answers 3


I know this was asked a while ago, but posting this in case anyone else needs it:


This gist takes the steps from this comment on d.o. and makes it into a simple script: https://drupal.org/node/1806220#comment-6960906

Here's the steps from the linked comment:

  1. backup your site and db
  2. copy the table for your field (and the revisions table for the field) to make a backup (in my case i copied: field_data_field_attachments to field_data_field_attachments_bk)
  3. empty table field_data_field_attachments
  4. go to drupal and the option to change the file system should be available, so change it
  5. copy all data from field_data_field_attachments_bk back to field_data_field_attachments
  6. go to drupal, select your content type, select your file field, in file path settings select retroactive update
  7. click save and it will move all your files to the right place in file system and update your db to the new path

I ran through the script and field updates on several fields myself recently and it just works.


Use https://www.drupal.org/project/privatize, a drush extension to convert the files for you.


In the Home » Administration » Configuration » Media path
you should set your private file path to sites/default/private.
This will automatically give you an option for public or private files while editing fields settings.

enter image description here

Then you can check in field settings and select private file . enter image description here

  • I'm afraid it might not be the case if there are files in that field already. If you tested it, please confirm one way or another.
    – Mołot
    Sep 12, 2013 at 6:47
  • will the files get deleted if we change the option from public to private?
    – harshal
    Sep 12, 2013 at 6:59
  • Changing the global setting in the file system settings won't effect an existing field that is already set to public. I am pretty sure I need to manually change this in the database, but Im not sure where to do it. I know that I can manually change the uri for the individual files in the file_managed table. I just don't know where to change the field settings for any new uploads.
    – Eazye1977
    Sep 12, 2013 at 18:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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