Retrieving response headers AND body in a single request

I was googling how to send files, for cURL I found this https://github.com/phplicengine/phplicengine-api/blob/master/lib/PHPLicengine/Api/FileUpload.php
For file_get_contents found no ready to use lib but I think I should create a multipart boundary with the stream, right?