これは、cURLを使用して実行できます。
// Open a stream so that we stream the image download
$localFile = $_FILES[$fileKey]['tmp_name'];
$stream = fopen($localFile, 'r');
// Create a curl handle to upload to the file server
$ch = curl_init($fileServer);
// Send a PUT request
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
// Let curl know that we are sending an entity body
curl_setopt($ch, CURLOPT_UPLOAD, true);
// Let curl know that we are using a chunked transfer encoding
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Transfer-Encoding: chunked'));
// Use a callback to provide curl with data to transmit from the stream
curl_setopt($ch, CURLOPT_READFUNCTION, function($ch, $fd, $length) use ($stream) {
return fread($stream, $length) ? '';
});
curl_exec($ch);