2

I have standalone script for adding some files to Drupal nodes. It is in main Drupal directory. It is multisite enviromnent. I know how to choose database and I am sure that I am choosing proper database, but my files lands in sites/default/files but I want them in sites/domain/files. I am getting public files path by

drupal_realpath('public://')

It returns sites/default/files.

All other things are correct and file data lands in proper database.

I checked site (admin/config/media/file-system) that database I am using and this path is set to site/domain/files...

Is there any chance to set public path programmatically? So file_copy will use proper path.

EDIT

The reason that I am asking is that my hooks: hook_file_presave doesn't invoke and I am thinking that is because public path problem. (All required module are enabled)

In single site env script works ok.

Probably the only solution is to create module, but it strange it isn't works. I wanted to stay away from creating modules for long running task because it's take longer and Batch API is slower that good old CLI. All my previous scripts worked with multisites.

2

You can set that variable like so:

variable_set('file_public_path', 'sites/domain/files');

Hopefully someone else will be able to tell you why this problem is happening, I have no such issue in any of my multisite installations.

  • Thanks a lot, it works. Hooks still doesn't invoke, but it is different problem. – Codium Sep 22 '12 at 11:26

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.