Использование:
if (function_exists('curl_file_create')) { // php 5.5+
$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);
Вы также можете обратиться:
http://blog.derakkilgo.com/2009/06/07/send-a- file-through-post-with-curl-and-php /
Важная подсказка для PHP 5.5 +:
Теперь мы должны использовать https: // wiki.php.net/rfc/curl-file-upload, но если вы все еще хотите использовать этот устаревший подход, вам нужно установить curl_setopt($ch, CURLOPT_SAFE_UPLOAD, false);