-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathjsonupload.php
More file actions
48 lines (33 loc) · 1.88 KB
/
jsonupload.php
File metadata and controls
48 lines (33 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
// JSON File Uploader
// Initially created to upload the test paramaters for multiple stock-trading bots running at the same time.
// You can upload a json file with any file name and it will automatically re-write a set json file on your web-server.
// This is useful if you are calling a static json url but need to update the values in the file frequently
// Best used for internal or privates directories. No safety measures were taken as this runs on a closed network for me
// Dan Wallace
if ( isset($_POST["submit"]) ) {
if ( isset($_FILES["file"])) {
// Upload Error
if ($_FILES["file"]["error"] > 0) {
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}else {
// Print details
echo "File Upload: " . $_FILES["file"]["name"] . "<br/>";
echo "File Type: " . $_FILES["file"]["type"] . "<br/>";
echo "File Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br/>";
// Check if the file exists
if (file_exists("uploads/" . $_FILES["file"]["name"])) {
echo $_FILES["file"]["name"] . " already exists. ";
}else {
// You can change the name of the static JSON file here
$storagename = "json_update.json";
// Save file in folder "upload"
move_uploaded_file($_FILES["file"]["tmp_name"], "uploads/" . $storagename);
echo "File Path: " . "uploads/" . $_FILES["file"]["name"] . "<br />";
}
}
} else {
echo "No file was selected. Try again. <br />";
}
}
?>