Update api.php
This commit is contained in:
parent
ca712c728c
commit
f6df8f516a
1 changed files with 22 additions and 2 deletions
24
api.php
24
api.php
|
@ -4,6 +4,7 @@ if(isset($_GET['d'])) {
|
||||||
//Include the core file with the functions
|
//Include the core file with the functions
|
||||||
include_once('includes/core.php');
|
include_once('includes/core.php');
|
||||||
switch ($_GET['d']) {
|
switch ($_GET['d']) {
|
||||||
|
//Uploading with HTML response and errors
|
||||||
case 'upload':
|
case 'upload':
|
||||||
//If no file is being posted, show the error page and exit.
|
//If no file is being posted, show the error page and exit.
|
||||||
if(empty($_FILES['file']['name'])){
|
if(empty($_FILES['file']['name'])){
|
||||||
|
@ -21,13 +22,32 @@ if(isset($_GET['d'])) {
|
||||||
$name = $_FILES['file']['name'];
|
$name = $_FILES['file']['name'];
|
||||||
$arg = 'random';}
|
$arg = 'random';}
|
||||||
//Call the save function which sends the file+name
|
//Call the save function which sends the file+name
|
||||||
save_file($_FILES['file']['tmp_name'], $name, $arg);
|
save_file($_FILES['file']['tmp_name'], $name, $arg, 'normal');
|
||||||
|
break;
|
||||||
|
//Uploading without HTML response or errors
|
||||||
|
case 'upload-tool':
|
||||||
|
//If no file is being posted, show the error page and exit.
|
||||||
|
if(empty($_FILES['file']['name'])){
|
||||||
|
exit('You did not send a file, try again.');
|
||||||
|
}
|
||||||
|
//Set the name value to the original filename
|
||||||
|
$name = $_FILES['file']['name'];
|
||||||
|
$arg = 'custom_original';
|
||||||
|
//If the value name contains a custom name, set the name value
|
||||||
|
if(!empty($_POST['name'])){
|
||||||
|
$name = $_POST['name'];}
|
||||||
|
//If value contains anything, keep original filename
|
||||||
|
if(!empty($_POST['randomname'])){
|
||||||
|
$name = $_FILES['file']['name'];
|
||||||
|
$arg = 'random';}
|
||||||
|
//Call the save function which sends the file+name
|
||||||
|
save_file($_FILES['file']['tmp_name'], $name, $arg, 'tool');
|
||||||
break;
|
break;
|
||||||
case 'extend-time':
|
case 'extend-time':
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
//If no correct valid argument for the api to perform on, tell them to enter a valid one
|
//If no correct valid argument for the api to perform on, tell them to enter a valid one
|
||||||
exit('Please provide a valid argument. Example: curl -i -F name=test.jpg -F file=@localfile.jpg http://uguu.se/api.php?d=upload');
|
exit('Please provide a valid argument. Example: curl -i -F name=test.jpg -F file=@localfile.jpg http://uguu.se/api.php?d=upload-tool');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
|
Loading…
Add table
Reference in a new issue