]>
Commit | Line | Data |
---|---|---|
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('includes/core.php'); | |
6 | switch ($_GET['d']) { | |
7 | case 'upload': | |
8 | //If no file is being posted, show the error page and exit. | |
9 | if(empty($_FILES['file']['name'])){ | |
10 | include('error.php'); | |
11 | exit(0); | |
12 | } | |
13 | //Set the name value to the original filename | |
14 | $name = $_FILES['file']['name']; | |
15 | $arg = 'custom_original'; | |
16 | //If the value name contains a custom name, set the name value | |
17 | if(!empty($_POST['name'])){ | |
18 | $name = $_POST['name'];} | |
19 | //If value contains anything, keep original filename | |
20 | if(!empty($_POST['randomname'])){ | |
21 | $name = $_FILES['file']['name']; | |
22 | $arg = 'random';} | |
23 | //Call the save function which sends the file+name | |
24 | save_file($_FILES['file']['tmp_name'], $name, $arg); | |
25 | break; | |
26 | case 'extend-time': | |
27 | break; | |
28 | default: | |
29 | //If no correct valid argument for the api to perform on, tell them to enter a valid one | |
30 | exit('Please provide a valid argument. Example: curl -i -F name=test.jpg -F file=@localfile.jpg http://uguu.se/api.php?d=upload'); | |
31 | break; | |
32 | } | |
33 | }else{ | |
34 | //*1 | |
35 | header('Location: index.html'); | |
36 | } |