Skip to content

Instantly share code, notes, and snippets.

@clone1018
Created March 18, 2013 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clone1018/5188150 to your computer and use it in GitHub Desktop.
Save clone1018/5188150 to your computer and use it in GitHub Desktop.
cURL
curl -X POST -d @/tmp/derp.png --header "Content-Type:text/plain" http://someurl/
<?php
$header = array('Content-Type:text/plain');
$resource = curl_init();
curl_setopt($resource, CURLOPT_URL, $url);
curl_setopt($resource, CURLOPT_HTTPHEADER, $header);
curl_setopt($resource, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($resource, CURLOPT_POST, 1);
curl_setopt($resource, CURLOPT_POSTFIELDS, array('@' . $file));
$result = json_decode(curl_exec($resource), true);
curl_close($resource);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment