]> jfr.im git - uguu.git/blob - api.php
Update README.md
[uguu.git] / api.php
1 <?php
2 //If the value d doesn't exist, redirect back to front page *1
3 if(isset($_GET['d'])) {
4 //Include the core file with the functions
5 include_once('core.php');
6 switch ($_GET['d']) {
7 case 'upload':
8 //Set the name value to the original filename
9 $name = $_FILES['file']['name'];
10 $arg = 'custom_original';
11 //If the value name contains a custom name, set the name value
12 if(!empty($_POST['name'])){
13 $name = $_POST['name'];}
14 //If value contains anything, keep original filename
15 if(!empty($_POST['randomname'])){
16 $name = $_FILES['file']['name'];
17 $arg = 'random';}
18 //Call the save function which sends the file+name
19 save_file($_FILES['file']['tmp_name'], $name, $arg);
20 break;
21 case 'extend-time':
22 break;
23 default:
24 //If no correct valid argument for the api to perform on, tell them to enter a valid one
25 exit('Please provide a valid argument. Example: curl -i -F name=test.jpg -F file=@localfile.jpg http://uguu.se/api.php?d=upload');
26 break;
27 }
28 }else{
29 //*1
30 header('Location: index.html');
31 }