Skip to content

Instantly share code, notes, and snippets.

@davidvanvickle
Created January 10, 2012 21:48
Show Gist options
  • Save davidvanvickle/1591407 to your computer and use it in GitHub Desktop.
Save davidvanvickle/1591407 to your computer and use it in GitHub Desktop.
php download a binary
$data = 'hello world';
$source_url = 'https://domain.com/chart?chid=' . md5(uniqid(rand(), true));
// params (http_build_query will later urlencode)
$qrcode = array(
'cht' => 'qr',
'chs' => '177x177',
'chl' => $data);
// send the request
$context = stream_context_create(
array('http' => array(
'method' => 'POST',
'content' => http_build_query($qrcode))));
// save the returned bytes
file_put_contents($savepath,fopen($source_url, 'r', false, $context));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment