Reputation: 1886
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?
Upvotes: 2
Views: 3098
Reputation: 5739
<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);
Upvotes: 5