Answers for "curl file upload"

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
0

linux curl upload file ftp

# curl -T backup-file.tar.gz ftp://username:[email protected]/backup/
Posted by: Guest on October-16-2020
0

CURL URL UPLOAD

<?php
// You can not use any http url for the file path at curl. You have to use local file. So first download the file into a temporary directory.


file_put_contents("/var/tmp/xyz/output.jpg", file_get_contents("https://www.google.com/images/srpr/logo11w.png"));

//Then use this temporary file into your curl:



'image' => '@/var/tmp/xyz/output.jpg'
??
Posted by: Guest on August-19-2021
-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