Passing / requesting image from second server (as variable?)

Hello.

I didn??t want to ask for help for this problem, but I have browsed the web to find a answer to my question for three days now…

Ok…

My problem is (with php) that I need to pass a image from one server to another without the need to tell the destination server where the image is.

Here is a code that works in one php file:

$picture = "cow.jpg";
$pictname = "cat.jpg";

$instr = fopen($picture,"rb");
$image = fread($instr,filesize($picture)); 

$f = fopen($pictname,"w");
fwrite($f,$image) 

The thought was to split the file in two peaces and place them on server1 and server2 eg.

//server1 where the image is
$picture = "cow.jpg";

$instr = fopen($picture,"rb");
$image = fread($instr,filesize($picture));
//Somehow print the image binary source
//server2 queries the image
$pictname = "cat.jpg";
$image = file_get_contents(server1.php)

$f = fopen($pictname,"w");
fwrite($f,$image) 
//write out the "new" image to disk.

I have also thought of just passing the absolute url to the image to server2 with file() and just use copy(), but can??t make it work.

I don??t understand how to make server1 write out a string i can use in server2 as a variable.

The point here is that the user on server 2 don??t ever get to know the absolute url to the image.

Any one got a easy solution to this problem?
Thx

I’m thinking sockets … PHP has a module for that, but it has to be installed and enabled on both servers for that boat to float. Not sure what other options there are for data transfer between servers.

Sponsor our Newsletter | Privacy Policy | Terms of Service