2
votes

Let's assume that i have 2 domains running on the same server, www.domain1.com and www.domain2.com.
I will use www.domain1.com for data transfer. basically this domain will form my website.
I would like to use www.domain2.com as my imageserver.

let's say the ftp structure looks like this:
(i hope this structure will come out readable, since i used alt[255] to space it. however, if it doesn't come out readable, is there a way to use emptyspace characters in SO?)

domains
|
+-- domain1.com
|     |
|     +-- public_html
|
+-- domain1.com
      |
      +-- public_html

is there a way for me to upload images from www.domain1.com to www.domain2.com in php?

1
You can use the file manipulation functions in PHP, assuming that the PHP has access to both domain directories.Scott Stevens
might be relatedtradyblix
you mean i just should use something like move_uploaded_file(domain1.com/public_html/tmp, ../../domain2.com/public_html)?Gabi Barrientos

1 Answers

5
votes
<pre><code>
$dir = $_SERVER['DOCUMENT_ROOT'].'/../domain2.com/';
$d = dir($dir);
echo "Handle: " . $d->handle . "\n";
echo "Path: " . $d->path . "\n";
while (false !== ($entry = $d->read())) {
   echo $entry."\n";
}
$d->close();
</code>
</pre>

You can try the obove code. When you get the list, you can handle your uploads by


    $dest_dir = $_SERVER['DOCUMENT_ROOT'].'/../domain2.com/YOURSTOREFOLDER/'
    $filename = 'hello_world.jpg';
    move_upload_file($uploadFileName,$dest_dir.$filename);