To upload a file using the NeoDrive API, send a POST request with the following parameters:
curl --location --request POST 'https://neodriveURL/upload/api' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode '[email protected]' \ --data-urlencode 'api_token=your_api_key' \ --data-urlencode 'url=FileID'
<?php
$data = array(
'email' => '[email protected]',
'api_token' => 'your_api_key',
'url' => 'FileID'
);
$options = array(
'http' => array(
'header' => "Content-Type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data),
),
);
$context = stream_context_create($options);
$response = file_get_contents('https://neodriveURL/upload/api', false, $context);
$response_data = json_decode($response, true);
if ($response_data['status']) {
echo "Upload successful. File URL: " . $response_data['data']['url'];
} else {
echo "Error: " . $response_data['message'];
}
?>
The API will return the following JSON response:
{
"status": true,
"code": 200,
"message": "Upload successful",
"data": {
"name": "FileName.mp4",
"url": "https://neodriveURL/file/UniqueID",
"share_id": "UniqueID"
}
}
In this response: