Skip to content

Instantly share code, notes, and snippets.

@kidker
Created August 2, 2016 06:42
Show Gist options
  • Save kidker/4e7391d306c81e058b82230f7cbc82aa to your computer and use it in GitHub Desktop.
Save kidker/4e7391d306c81e058b82230f7cbc82aa to your computer and use it in GitHub Desktop.
Curl Send File
http://blog.derakkilgo.com/2009/06/07/send-a-file-via-post-with-curl-and-php/
$file_name_with_full_path = realpath('./sample.jpeg');
$post = array('extra_info' => '123456','file_contents'=>'@'.$file_name_with_full_path);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$target_url);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$result=curl_exec ($ch);
curl_close ($ch);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment