-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreadImage.php
More file actions
91 lines (80 loc) · 1.88 KB
/
readImage.php
File metadata and controls
91 lines (80 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
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
85
86
87
88
89
90
91
<!Doctype html>
<html>
<head>
<title>Photo Details</title>
<style>
table, th, td {
border: 1px solid black;
}
</style>
</head>
<body>
<table>
<tr>
<th>Property</td>
<th>Value</td>
</tr>
<?php
error_reporting(0);
try
{
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/png")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 2000000))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
//Generate Image name
$_rand_name=rand(0,1000000000);
$name=$_FILES["file"]["name"];
$exploded=explode('.',$name);
$ext=$exploded[1];
echo "extension is ".$ext."<br/>".$_rand_name."<br/>";
$image_name=$_rand_name.".".$ext;
if (file_exists("uploads/" . $_FILES["file"]["name"]))
{
echo $image_name. " already exists. ";
}
else
{
//Move image to uploads folder
move_uploaded_file($_FILES["file"]["tmp_name"],
"uploads/".$image_name);
echo "Stored in: " . "uploads/" .$image_name;
echo "<br />";
//Extract Photo Details using exif
$image = "uploads/" .$image_name;
$exif = exif_read_data($image, 0, true);
foreach ($exif as $key => $section) {
foreach ($section as $name => $val) {
if($name != "MakerNote")
{
echo "<tr><td>$name:</td><td> $val</td></tr>";
}
}
}
}
}
}
else
{
echo "Invalid file";
header('refresh:2;url=index.php');
}
}
catch(Exception $e)
{}
?>
</table>
</body>
</html>