-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupload.php
executable file
·84 lines (47 loc) · 1.92 KB
/
upload.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
include'db.php';
$connection = mysqli_connect($host_name, $user_name, $password, $database) or die(mysqli_error);
session_start();
$dir = $_SESSION['id'];
$target_dir = "/var/www/html/webday/name/$dir/";
move_uploaded_file($_FILES["userfile"]["tmp_name"][$val], $target_file);
foreach ($_FILES["userfile"]["error"] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$tmp_name = $_FILES["userfile"]["tmp_name"][$key];
$name = $_FILES["userfile"]["name"][$key];
move_uploaded_file($tmp_name, "$target_dir/$name");
$path_parts = pathinfo("$target_dir/$name");
$ext = $path_parts['extension'];
if($ext == "jpg" or $ext == "JPG"){
$exif = exif_read_data("$target_dir/$name");
$ImageID = md5_file("$target_dir/$name");
echo "$ImageID";
$ImageDate = $exif['DateTime'];
$lon = getGps($exif["GPSLongitude"], $exif['GPSLongitudeRef']);
$lat = getGps($exif["GPSLatitude"], $exif['GPSLatitudeRef']);
echo "$ImageID <br>";
if(isset($ImageID)){
$sql = "insert into image (imageId,DateTime,GPSLAT,GPSLON) values ('$ImageID','$ImageDate',$lat,$lon)";
mysqli_query($connection,$sql);
}
}
}
}
function getGps($exifCoord, $hemi) {
$degrees = count($exifCoord) > 0 ? gps2Num($exifCoord[0]) : 0;
$minutes = count($exifCoord) > 1 ? gps2Num($exifCoord[1]) : 0;
$seconds = count($exifCoord) > 2 ? gps2Num($exifCoord[2]) : 0;
$flip = ($hemi == 'W' or $hemi == 'S') ? -1 : 1;
return $flip * ($degrees + $minutes / 60 + $seconds / 3600);
}
function gps2Num($coordPart) {
$parts = explode('/', $coordPart);
if (count($parts) <= 0)
return 0;
if (count($parts) == 1)
return $parts[0];
return floatval($parts[0]) / floatval($parts[1]);
}
mysqli_close($connection);
?>
<script>history.go(-1) </script>