upload a file to server without using a form? upload a file to server without using a form? curl curl

upload a file to server without using a form?


This is an example of file uploading with cURL you could start with:

$ch = curl_init('http://api.blabla.com/huhu.php');curl_setopt_array($ch, array(    CURLOPT_POSTFIELDS => array(        'files[]' => '@/path/to/file',    ),));if (false === ($res = curl_exec($ch))) {    die("Upload failed: " . curl_error($ch));}

The string '@/path/to/file' has a special meaning because it starts with an @; the string that directly follows it should contain the path of a file you wish to upload.