3

how can I change my Drupal filesystem root in the database ? I moved Drupal to another path. I'm looking for this value to update in the database. thanks

4 Answers 4

3

<EDIT>if you want to change it in the database (why?), you can do it by changing the value of file_directory_path in the variable table:

UPDATE variable SET file_directory_path = 's:5:"files";';

values in the variable table are stored as serialized php variables. the serialized value in the example above means file_directory_path is a string (s) of length 5 with the value files. you have to adapt this to your specific value.

also note that Drupal variables are cached (in the cache table, under the cid variables). for your change in the database to take effect, you have to clear that cache, like DELETE FROM cache WHERE cid = 'variables';.</EDIT>

if you mean the File system path: it's at Administer > Site configuration > File system, or http://yourdrupalsite.com/index.php?q=admin/settings/file-system.

4
  • yeah I mean the file system path, but I meant changing it in the database, not using drupal
    – aneuryzm
    Apr 26, 2010 at 11:33
  • sorry I guess there is my misunderstanding. In Drupal database there are only relative paths (starting from the Drupal root folder) and not an absolute one (i.e. /web/Drupal) specifying where Drupal is installed, right ? This is what I meant
    – aneuryzm
    Apr 28, 2010 at 6:26
  • yes: Drupal paths are relative to the Drupal root folder. this root folder, however, is not stored anywhere in the database. there is no need for it. if you move your installation to a new folder and can call its index.php from a browser, it will just work.
    – ax.
    Apr 28, 2010 at 13:12
  • so is your question answered?
    – ax.
    May 3, 2010 at 15:21
1

You could also do the following:

//Get the path of the files folder (ex. sites/default/files)
$files_dir = variable_get('file_directory_path', '');

//To set a new path programmatically
variable_set('file_directory_path', 'sites/new-path/files');
0

Funny, I just had to do that yesterday.

Since i have phpmyadmin available to me, I used that to export the files table, then do some search/replace routines, then import the table, overwriting the data.

But had I not had phpmyadmin to help, I would have created an SQL query to replace the outdated paths...

1
  • hi! I thought that the main location of drupal installation on the server was stored only once. (Then all the relative paths.. (i.e. sites/files... ) are repeated a lot of times, but I don't need to change them.
    – aneuryzm
    Apr 26, 2010 at 23:27
0

Funny, I just moved my drupal to another folder, and it was working. Probably I didn't explain my question very well..

1
  • 2
    patrick - that is exactly what i said in a comment to my answer. please don't take other peoples info and make it into your own, accepted answer. thanks!
    – ax.
    May 21, 2010 at 5:33

Your Answer

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

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