In order to send a file you must perform an HTTP POST request to the following URL:
<?php
$apiurl = "https://www.bffile.com/API/V1/";//Upload API
$file = __DIR__."/123.txt";//File path to upload (first file)
$file2 = "/path/to/fullfilename.ext";//File path to upload (second file), and so on
$filename1 = '';//File name, including the Filename Extension (EX:demo.zip);If it is null, the system will get it automatically.
$filename2 = '';/ //Second file name, and so on
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL,$apiurl);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, [
'fileupload[0]' => curl_file_create($file, '', $filename1),
'fileupload[1]' => curl_file_create($file2, '', $filename2), //Multiple files (and so on)
'price' => '',//File price (free of documents, please leave blank)
'comment' => '',//File description
'api_token' => '',//Upload API Token(You can log in to the homepage to view; if left blank, it means visitors.)
'password' => ''//File password
]);
$result = curl_exec($ch);
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($status_code == 200) { // OK
$obj = json_decode($result, true);
if ($obj['results']){
foreach($obj['results'] as $subresult) {
if(isset($subresult['error']) && $subresult['error']) {
echo $subresult['message']; // Error Message For Each file
} else {
echo $subresult['filename'].'<br>';// Output filename
echo $subresult['md5'].'<br>';// Output file MD5
echo $subresult['deletehash'].'<br>';//Output file deletion hasg
echo $subresult['urlhash'].'<br>';//Output download URL hash
echo $subresult['filesize'].'<br>';//Output file size (byte)
echo $subresult['message'];//Show message(EX: Successful upload)
}
}
}else{
echo $obj['message'];//Show message
}
} else { // Error occured
print($result);
}
if (!function_exists('curl_file_create')) { // support func for PHP <= 5.5
function curl_file_create($filename, $mimetype = '', $postname = '') {
return "@$filename;filename="
. ($postname ?: basename($filename))
. ($mimetype ? ";type=$mimetype" : '');
}
}
?>
In order to retrieve a detail on a given File you must perform an HTTP GET request to the following URL: