Forum Moderators: coopster

Message Too Old, No Replies

copy file from domain to subdomain

         

cnapsys

5:48 pm on Aug 12, 2011 (gmt 0)

10+ Year Member



Hey all,
I've been playing with this script for the last couple of hours:

$path1 = "/var/www/vhosts/domain.com/httpdocs/new/test/test.jpg";
$path2 = "/var/www/vhosts/domain.com/subdomains/img/httpdocs/test/test.jpg";

if (!copy($path1, $path2)) {
echo "failed to copy file...";
}

error reporting is disabled so I can't see the actual error but I'm assuming it's got something to do with permissions.

I guess it should work if /test/ on the subdomain was set to chmod 777 but really don't wanna do that.
What are my options?

Any help is greatly appreciated

c

httpwebwitch

6:07 pm on Aug 12, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



chmod that thing to 777 for 10 seconds while you try it. then chmod it back again. At least then you'll know if it's a permission problem or something else.

if it's just the /test/ folder, there shouldn't be any harm doing that for a few seconds.

Apache/PHP has restrictions based on file ownership that I don't fully comprehend, it's incapable of doing any writing outside of the DocumentRoot (and I guess 99% of the time that's a good thing)

cnapsys

6:29 pm on Aug 12, 2011 (gmt 0)

10+ Year Member



hmmm I actually tried chmod 777 on /test/ on the subdomain and it still didn't work :(

/sadpanda

I'm kinda lost now

penders

7:06 pm on Aug 12, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



...presumably copy($path2,$path1) is OK?

cnapsys

7:11 pm on Aug 12, 2011 (gmt 0)

10+ Year Member



got the paths from a phpinfo() from both locations

cnapsys

7:29 pm on Aug 12, 2011 (gmt 0)

10+ Year Member



yeah I just double checked the paths with realpath() and getcwd()
they are both ok

cnapsys

5:33 pm on Aug 30, 2011 (gmt 0)

10+ Year Member



So after digging a bit more I found out that it is an open_basedir restriction.
Is there a way to do this without turning open_basedir off?

I thought about having a perl script running on the server with proper permissions and then maybe call it from php?
Not sure what the best method is or what other options are there?

Anyone that has ever dealt with something similar... your input would be awesome

ty for your time

c