Hi all,
I'm working with the following section of php code. The purpose is to POST an image file from one server to another. This works perfectly and very quickly as long as the file is < ~250k. Much over 250k, and the process time jumps to ~60 seconds, and increases from there with image size.
Any ideas?
Thanks!
John
$fileContents = file_get_contents($_FILES[$key]['tmp_name']);
$time = strtotime("now");
$body = "--f6sd54c2
Content-Disposition: form-data; name=\"id\"
Content-Length: " . strlen($id) . "
{$id}
--f6sd54c2
Content-Disposition: form-data; name=\"key\"
Content-Length: " . strlen("654t2bsr65t42czd13fvs6dry87") . "
654t2bsr65t42czd13fvs6dry87
--f6sd54c2
Content-Disposition: form-data; name=\"time\"
Content-Length: " . strlen($time) . "
{$time}
--f6sd54c2
Content-Disposition: form-data; name=\"photo\"; filename=\"photo.jpg\"
Content-Type: image/jpeg
Content-Length: " . strlen($fileContents) . "
{$fileContents}
--f6sd54c2--";
$headers = "POST /photos/process.php HTTP/1.1
Host: www.hostname.com
Keep-Alive: 300
Connection: keep-alive
Content-Type: multipart/form-data; boundary=f6sd54c2
Content-Length: " . strlen($body) . "
";
$fp = fsockopen("www.hostname.com", 80, $errno, $errstr);
if ($fp){
fwrite($fp, $headers . $body);
fclose($fp);
}