initial commit
This commit is contained in:
commit
9c93cdaa8a
|
|
@ -0,0 +1 @@
|
|||
php-8.4.5-nts-Win32-vs17-x64
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
dagenio File Receiver
|
||||
|
||||
Starts PHP Server on Port 8000 and listens for Files:
|
||||
|
||||
Install:
|
||||
- Download Windows PHP Binaries and place it in dagenioFileReceiver Folder
|
||||
- replace "php-8.4.5-nts-Win32-vs17-x64" with your version in dagenioFileReceiver.bat
|
||||
|
||||
getting started:
|
||||
- change Auth Token in Config
|
||||
- Setup possible Directories for storing files
|
||||
|
||||
URL:
|
||||
- http://<ip>:8000/
|
||||
|
||||
HTTP Request:
|
||||
Method
|
||||
- POST
|
||||
Authorization
|
||||
- Bearer
|
||||
Body:
|
||||
- form-data
|
||||
Params:
|
||||
- folder -> use short key from Config e.g. "uploads"
|
||||
- file
|
||||
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
$arrConfig = [
|
||||
'auth' => [
|
||||
'bearer' => 'Mfz8PMmjqQPwZEhr2v1z',
|
||||
],
|
||||
'directories' => [
|
||||
'uploads' => [
|
||||
'path' => 'C:\\dagenioFileReceiver\\uploads\\',
|
||||
],
|
||||
|
||||
'uploads2' => [
|
||||
'path' => 'C:\\dagenioFileReceiver\\uploads2\\',
|
||||
],
|
||||
],
|
||||
];
|
||||
?>
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
php-8.4.5-nts-Win32-vs17-x64\php.exe -S 0.0.0.0:8000 dagenioFileReceiver.php
|
||||
pause
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
require_once('config.php');
|
||||
|
||||
//Bearer Auth
|
||||
if(@$_SERVER['HTTP_AUTHORIZATION'] != 'Bearer '.$arrConfig['auth']['bearer']){
|
||||
response(403, 'invalid Bearer Token');
|
||||
}
|
||||
|
||||
if(!empty($_POST['folder'])){
|
||||
foreach($arrConfig['directories'] as $key=>$config){
|
||||
if($_POST['folder']==$key){
|
||||
$uploaddir = $config['path'];
|
||||
$uploadfile = $uploaddir . basename( $_FILES['file']['name']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)){
|
||||
response(200, "The file has been uploaded successfully");
|
||||
}
|
||||
|
||||
else{
|
||||
response(500, "There was an error uploading the file");
|
||||
}
|
||||
|
||||
} else {
|
||||
response(422, 'parameter folder is missing');
|
||||
}
|
||||
|
||||
function response($code, $message){
|
||||
echo json_encode(['message'=>$message]);
|
||||
header("HTTP/1.1 ".$code.' '.getCodeStatus($code));
|
||||
die();
|
||||
}
|
||||
|
||||
function getCodeStatus($code){
|
||||
$arrCode = [
|
||||
200 => 'OK',
|
||||
403 => 'Forbidden',
|
||||
422 => 'Unprocessable Entity',
|
||||
500 => 'Server Error',
|
||||
];
|
||||
return $arrCode[$code];
|
||||
}
|
||||
?>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.8 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.8 MiB |
Loading…
Reference in New Issue