It turned out that when sending the request, a Expect
header is added to the request. So what I did was remove the Expect
header before sending the request, and everything is working as it should. Following is the code that I changed:
$request = $client
->post('receiveFile')
->addPostFields(array('current_time'=>$current_time))
->addPostFile('file', $file)
->removeHeader('Expect')
->send();
I used the removeHeader
method to remove the Expect
header. Looks like the removeHeader
method must be called just before using the send
method, because I had used it before the post
method and it hadn't worked before.