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);

Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
php curl to upload file from url php curl to upload file php curl file upload upload file from url curl php php 7 curl upload file curl upload file php with login php curl upload image upload file through curl php 5.3 curl php send file php upload file curl how to post a file with curl in php how to upload file using curl in php from url how to upload file using curl in php upload image curl php how to send file curl php curl php file upload php file upload curl send files with curl php send file through curl call php 7 send file through curl call php send file using curl php curl upload file php with form data php curl upload upload file with curl php upload file in rest api using curl in php curl for upload file php send file using curl in php php curl upload file from url php send file via curl send file data in curl php send file in curl php php curlfile upload send file curl php upload file to link php curl php upload files with curl Send file curl post PHP send file with curl php file upload in curl php upload files using curl php curl upload file php curl with file curl post file request php upload files using "GET" METHOD CURL send files via curl php upload file curl post image using curl php curl php post filename curl file upload upload file with curl post php upload file using curl php php curl push file curl post file php post file in curl php php curl post file upload file curl php php curl send file curl upload php file upload file curl in php curl file upload php php curl upload file php curl post file path php request file upload using curl curl upload file php php curl-file-upload example php upload file via curl
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source