]>
jfr.im git - uguu.git/blob - api.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');
7 //Uploading with HTML response and errors
9 //If no file is being posted, show the error page and exit.
10 if(empty($_FILES['file']['name'])){
11 include_once('error.php');
14 //Set the name value to the original filename
15 $name = $_FILES['file']['name'];
16 $arg = 'custom_original';
17 //If the value name contains a custom name, set the name value
18 if(!empty($_POST['name'])){
19 $name = $_POST['name'];}
20 //If value contains anything, keep original filename
21 if(!empty($_POST['randomname'])){
22 $name = $_FILES['file']['name'];
24 //Call the save function which sends the file+name
25 save_file($_FILES['file']['tmp_name'], $name, $arg, 'normal');
27 //Uploading without HTML response or errors
29 //If no file is being posted, show the error page and exit.
30 if(empty($_FILES['file']['name'])){
31 exit('You did not send a file, try again.');
33 //Set the name value to the original filename
34 $name = $_FILES['file']['name'];
35 $arg = 'custom_original';
36 //If the value name contains a custom name, set the name value
37 if(!empty($_POST['name'])){
38 $name = $_POST['name'];}
39 //If value contains anything, keep original filename
40 if(!empty($_POST['randomname'])){
41 $name = $_FILES['file']['name'];
43 //Call the save function which sends the file+name
44 save_file($_FILES['file']['tmp_name'], $name, $arg, 'tool');
49 //If no correct valid argument for the api to perform on, tell them to enter a valid one
50 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');
55 header('Location: index.html');