I'm trying to send a file using curl and PHP on anonfile but I get this json:
{"status":false,"error":{"message":"No file chosen.","type":"ERROR_FILE_NOT_PROVIDED","code":10}}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://anonfile.com/api/upload");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,'test.txt');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec($ch);
print_r($server_output);
curl_close ($ch);
In other words, how to translate this command into PHP?
curl -F "file=@test.txt" https://anonfile.com/api/upload
I tried several examples out there but still no clue
$target_url = 'https://anonfile.com/api/upload';
$args['file'] = '@/test.txt';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$target_url);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$result=curl_exec ($ch);
curl_close ($ch);
echo $result;