curl file upload code example
Example 1: php upload file via curl
if (function_exists('curl_file_create')) {
$cFile = curl_file_create($file_name_with_full_path);
} else {
$cFile = '@' . realpath($file_name_with_full_path);
}
$post = array('extra_info' => '123456','file_contents'=> $cFile);
$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);
Example 2: how to download a file with curl
curl "http://standards-oui.ieee.org/oui/oui.txt" --output macvendors.txt
Example 3: curl upload file
curl -F "FIELDNAME=@FILE" http:
Example 4: linux curl upload file ftp