-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnew-facade.php
64 lines (59 loc) · 1.96 KB
/
new-facade.php
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?
require_once("settings.php");
if(!isset($_FILES["facade_image"]) || !isset($_POST["lat"]) ||
!isset($_POST["lng"]) || !isset($_POST["alt"]) || !isset($_POST["scale"])) {
?>
<html>
<body>
<form enctype="multipart/form-data" action="new-facade.php" method="POST">
<label for="file">Filename:</label>
<input type="file" name="facade_image" id="file" />
<br />
<label for="lat">Latitude:</label>
<input type="text" name="lat" id="lat" />
<br />
<label for="lng">Longitude:</label>
<input type="text" name="lng" id="lng" />
<br />
<label for="alt">Altitude:</label>
<input type="text" name="alt" id="alt" />
<br />
<label for="scale">Scale:</label>
<input type="text" name="scale" id="scale" />
<br />
<input type="submit" name="submit" value="Upload" />
</form>
</body>
</html>
<?
}
else {
require_once("db-connect.php");
require_once("json-response.php");
$uploadDirectory = $SETTINGS["UPLOAD_DIR"];
$filename = basename($_FILES["facade_image"]["name"]);
$uploadDestination = $uploadDirectory . $filename;
$filename = mysql_escape_string($filename);
$lat = mysql_escape_string($_POST["lat"]);
$lng = mysql_escape_string($_POST["lng"]);
$alt = mysql_escape_string($_POST["alt"]);
$scale = mysql_escape_string($_POST["scale"]);
if(move_uploaded_file($_FILES["facade_image"]["tmp_name"],
$uploadDestination)) {
$query = "INSERT INTO `facades` SET `user` = 1, `lat` = $lat, " .
"`lng` = $lng,`alt` = $alt, `scale` = $scale, " .
"`timetaken` = NOW(), `timeuploaded` = NOW(), " .
"`imgurl` = '$uploadDestination', `processed` = 0";
if(!mysql_query($query)) {
json_error(500, "Could not insert a record into the database: " .
mysql_error());
}
else {
json_success(array("response" => "Success"));
}
}
else {
json_error(500, "Could not copy uploaded file.");
}
}
?>