including / opening files from another user account in PHP

carbon.wpa

New member
Joined
Jun 12, 2012
Messages
3
Hello Guys,

I have following problem: I would like to configure my server that one of account would be "global server account" I mean that it will be avaliable to copy/include files from another account of my server.

Let's say that I have following path:

/home/globalaccount/domains/example.com/public_html/

And following files:

- template.php
- image.jpg

1. And I would like to include above file on another account

<?
include('/home/globalaccount/domains/example.com/public_html/template.php');
?>

2. I aslo would like to copy files form above account

<?
$file = '/home/globalaccount/domains/example.com/public_html/image.jpg';
$newfile = 'example.jpg';

if (!copy($file, $newfile)) {
echo "failed to copy $file...\n";
}

?>

Of course those two example doesn't work at all at this time. How to reconfigure server to have easy access to "globalaccount" user files????

Thank you!
 
Hello,

The best and easiest way would be to move a directory with global files out of /home/ directory and add its path to include_dir in php.ini
 
Hi Alex,

Can you give me some exmaple. Which directrory would be easier to configure? And waht abount copy files? include_path will be neccesary to include files and copy files as well?
 
Which directrory would be easier to configure?

Whatever you want... if you've got root access you can do it anywhere on your server, e.g.

mkdir /usr/local/hosting_shared/
chmod 711 /usr/local/hosting_shared/

And add /usr/local/hosting_shared/ into either include_dir or open_basedir (or even both) in php.ini

include_path will be neccesary to include files and copy files as well?

Depends on your settings...
 
Thnak you Alex,

I have found simplier solution i just disable open_basedir in admin. It works perfeclty with include function but copy file still got permission denied despite of fopen works perfectly. Any clues?
 
hi alex , i can include file from directory in out of /home
i would like include file to /home directory
can you help me ?
 
Back
Top