-
Notifications
You must be signed in to change notification settings - Fork 1
/
newImage.php
79 lines (59 loc) · 2.51 KB
/
newImage.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
<html>
<head>
<title>Pipoca</title>
<link rel="stylesheet" type="text/css" href="css/main.css">
<script>
function checkImage() {
var img = new Image();
img.src = "sources/" + document.getElementById('name').value;
img.style = "visibility: hidden;";
img.onerror = function() {
// doesn't exist or error loading
alert('no image: sources/' + document.getElementById('name').value);
};
img.onload = function() {
alert('image OK');
}
}
</script>
</head>
<body>
<div id="#tudo">
<object data="css/logo.svg" type="image/svg+xml" height=200 width=900></object>
<div id="menu">
<?php include("menu.html"); ?>
</div>
<div id="centro">
<h2>Include a new image</h2>
<form method="post" action="doNewImage.php" enctype="multipart/form-data">
<input type="hidden" id="status" name="status" size="1" value="1">
<table border=0>
<tr><td><span class='fieldname'>file:</span></td><td><input type="file" name="fileToUpload" id="fileToUpload"></td></tr>
<tr><td><span class='fieldname'>owner:</span></td><td><input type="text" id="owner" name="owner" size="20" value="Leo"></td></tr>
<tr><td><span class='fieldname'>type:</span></td><td><select id="type" name="type"><option value="i">image</option><option value="v">video</option></select></td></tr>
<tr><td><span class='fieldname'>description:</span></td><td><textarea rows=4 cols=60 id="memo" name="memo" placeholder="Description of the image (remember that you can use attributes)"></textarea></td></tr>
<tr><td colspan=2><h2>Attributes</h2></td></tr>
<?php
include("connection.php");
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
// lista de caixas para os atributos
$sql = "SELECT id, name, memo FROM attributes";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result)) {
echo "<tr><td><span class='fieldname'>".$row["name"] . ":</span></td><td><input type='hidden' name='atributos[]' value='" . $row["id"] . "'><input type='text' name='valorAtributos[]'></td></tr>\n";
}
}
mysqli_close($conn);
?>
<tr><td colspan=2><input type="submit" name="submit" value="Send"></form></td></tr>
</table>
</div>
</div>
</body>
</html>