I finished writing a website and am currently deploying it on a hosting service. This website consists out of 2 separate domains hosted on the same server. (www.domain1.com & www.domain2.com)
Situation
When moving these domains to the hosting service, I figured that 1 script is not working as it was on the local server. This script is a custom upload class in php. This script is located on www.domain1.com but needs to upload the file to www.domain2.com.
My local server is a Xampp server with a simple file structure.
C:/xampp/htdocs
Domain1/uploadscript.php
Domain2/destinationfolder/
I am currently using the $_SERVER['DOCUMENT_ROOT']
function to navigate towards the other domain. This method works fine for the local server but not on the hosted version see below.
Main issue
Local server
print_r ($_SERVER['DOCUMENT_ROOT']);
= C:/xampp/htdocs
On domain1.com
print_r ($_SERVER['DOCUMENT_ROOT']);
= /home/myname/domains/domain1/public_html/
On domain2.com
print_r ($_SERVER['DOCUMENT_ROOT']);
= /home/myname/domains/domain2/public_html/
The $_SERVER['DOCUMENT_ROOT']
is not pointing to the "domains" folder but already is pointing to the "public_html".
The question(s)
How do I navigate towards the "domains" folder on my server? Are there other things necessary for cross domain uploading?