Strange delay POSTing from php fsockopen

oldskool

New Member
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\[code\]$fileContents = file_get_contents($_FILES[$key]['tmp_name']);$time = strtotime("now");$body = "--f6sd54c2Content-Disposition: form-data; name=\"id\"Content-Length: " . strlen($id) . "{$id}--f6sd54c2Content-Disposition: form-data; name=\"key\"Content-Length: " . strlen("654t2bsr65t42czd13fvs6dry87") . "654t2bsr65t42czd13fvs6dry87--f6sd54c2Content-Disposition: form-data; name=\"time\"Content-Length: " . strlen($time) . "{$time}--f6sd54c2Content-Disposition: form-data; name=\"photo\"; filename=\"photo.jpg\"Content-Type: image/jpegContent-Length: " . strlen($fileContents) . "{$fileContents}--f6sd54c2--";$headers = "POST /photos/process.php HTTP/1.1Host: www.hostname.comKeep-Alive: 300Connection: keep-aliveContent-Type: multipart/form-data; boundary=f6sd54c2Content-Length: " . strlen($body) . "";$fp = fsockopen("www.hostname.com", 80, $errno, $errstr);if ($fp){ fwrite($fp, $headers . $body); fclose($fp);}\[/code\]
 
Back
Top