Answers for "upload file curl"

PHP
1

php upload file via curl

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);
Posted by: Guest on August-13-2020
-1

curl upload file

curl -F "FIELDNAME=@FILE" http://URL 
# FIELDNAME can be whatever you want, it is the key value of the form field
# the @ is important to point to a local file
Posted by: Guest on January-09-2021

Browse Popular Code Answers by Language