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.