Skip to content

Instantly share code, notes, and snippets.

@aaryadev
Created April 6, 2015 16:29
Show Gist options
  • Save aaryadev/2f5aeea3e2eb4817e63d to your computer and use it in GitHub Desktop.
Save aaryadev/2f5aeea3e2eb4817e63d to your computer and use it in GitHub Desktop.
Post file to server via php (cUrl)
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, array('file' => '@/path/to/file.txt'));
curl_setopt($ch, CURLOPT_URL, 'http://server2/upload.php');
curl_exec($ch);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment