Skip to content

Instantly share code, notes, and snippets.

@sidchilling
Created November 30, 2012 19:56
Show Gist options
  • Select an option

  • Save sidchilling/4178150 to your computer and use it in GitHub Desktop.

Select an option

Save sidchilling/4178150 to your computer and use it in GitHub Desktop.
POST with file upload using Requests
<?php
# Include Requests.php and autoload the internal classes
$data = array(
'owner' => 'siddharth saha',
'test_file' => '@' . $file_path # File name to be pre-pended with @
);
$response = Requests::request($url, array(), $data, Requests::POST);
if ($response->success) {
$response = json_decode($response->body);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment