Server to Server Picture Transfer

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
AGISB
Forum Contributor
Posts: 422
Joined: Fri Jul 09, 2004 1:23 am

Server to Server Picture Transfer

Post by AGISB »

I am working on a system to manage Advertising on different domains from one admin area. To share the performance it is required that the banners are served from each domain.

1. Advertiser uploads the banner inside the admin area.
2. Advertiser decides where (on what domain) to advertise.
3. System must copy the banner to the required domains
4. Banner is served from the domains

I am wondering how to best move the pictures over to the other server when I might not know the ftp user and pass.

My second thought was to to output the binary data as text and fetch it from the other server but this seems top be like a bad idea due to possible encoding limitations.

My second thought is to use a post request described here http://www.php-faq.de/q-code-post.html (in German)

Code: Select all

function PostToHost($host, $path, $referer, $data_to_send) {
  $fp = fsockopen($host, 80);
  printf("Open!\n");
  fputs($fp, "POST $path HTTP/1.1\r\n");
  fputs($fp, "Host: $host\r\n");
  fputs($fp, "Referer: $referer\r\n");
  fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
  fputs($fp, "Content-length: ". strlen($data_to_send) ."\r\n");
  fputs($fp, "Connection: close\r\n\r\n");
  fputs($fp, $data_to_send);
  printf("Sent!\n");
  while(!feof($fp)) {
      $res .= fgets($fp, 128);
  }
  printf("Done!\n");
  fclose($fp);
 
  return $res;
}
 
$data = "pid=14&poll_vote_number=2";
 
printf("Go!\n");
$x = PostToHost(
              "www.linux.com",
              "/polls/index.phtml",
              "http://www.linux.com/polls/index.phtml?pid=14",
              $data
);
but I am not sure how I can add the binary data of a banner to it. Can anyone help me to add a picture to the post request?
AGISB
Forum Contributor
Posts: 422
Joined: Fri Jul 09, 2004 1:23 am

Re: Server to Server Picture Transfer

Post by AGISB »

Post Reply