Bij aanroepen pagina wordt record in database geschreven.
Wat is hiervan het probleem?
Alsvast bedankt!
Code:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
include ('connect.php');
/**************** Configuratie *****************/
$file_mimes = array('image/jpeg','image/jpg'); // Toegestane bestand Mime Types. Voeg zonodig meer mime types toe.
$file_exts = array('.jpg', '.gif'); // Toegestane bestand extensies. Voeg zonodig meer mime-types toe.
$upload_dir = "../foto/"; // Map waar alle uploads opgeslagen worden. (eindigend op "/")
$aantal_u = "1"; // Aantal mogelijke uploads per keer
$up_empty = "Leeg"; // Boodschap bij leeg uploadveld.
$up_finish = "De foto is succesvol toegevoegd aan de database."; // Boodschap bij Geslaagde upload.
$up_fail = "Mislukt"; // Boodschap bij mislukte upload.
$up_perm = "Veranderen van de permissies naar 777 is mislukt"; // Boodschap bij mislukken van veranderen permissies
?>
include ('connect.php');
/**************** Configuratie *****************/
$file_mimes = array('image/jpeg','image/jpg'); // Toegestane bestand Mime Types. Voeg zonodig meer mime types toe.
$file_exts = array('.jpg', '.gif'); // Toegestane bestand extensies. Voeg zonodig meer mime-types toe.
$upload_dir = "../foto/"; // Map waar alle uploads opgeslagen worden. (eindigend op "/")
$aantal_u = "1"; // Aantal mogelijke uploads per keer
$up_empty = "Leeg"; // Boodschap bij leeg uploadveld.
$up_finish = "De foto is succesvol toegevoegd aan de database."; // Boodschap bij Geslaagde upload.
$up_fail = "Mislukt"; // Boodschap bij mislukte upload.
$up_perm = "Veranderen van de permissies naar 777 is mislukt"; // Boodschap bij mislukken van veranderen permissies
?>
<html>
<head>
<title>Uploaden foto's</title>
</head>
<body bgcolor=cccccc>
Code (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
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
<?PHP
$url_dir = "http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
$url_this = "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
$upload_url = $url_dir."/".$upload_dir."/";
if($_REQUEST[upload])
{
/************* Maak Upload Map *****************/
if (!is_dir("$upload_dir"))
{
if (!mkdir($upload_dir))
die ($upload_dir."map bestaat niet en het aanmaken is mislukt.");
if (!chmod($upload_dir,0777))
die ($upload_dir.", ".$up_perm.".");
}
/********** Begin Controle En Upload **************/
for($x = 0; $x < $aantal_u; $x++)
{
$upfile = 'upfile_'.$x;
$file_name = $_FILES[$upfile]['name'];
$file_type = $_FILES[$upfile]['type'];
$file_ext = strtolower(substr($file_name,strrpos($file_name,".")));
echo "<b>Upload ".($x+1).":</b> ";
if ($file_name != "" && $file_type != "")
{
if (!in_array($file_type, $file_mimes) && !in_array($file_ext, $file_exts))
{
echo "<b><font color=\"FF0000\">".$up_fail."</font></b><br>\n";
}
else
{
$temp_name = $_FILES[$upfile]['tmp_name'];
$file_name = $_FILES[$upfile]['name'];
$file_name = str_replace("\\","",$file_name);
$file_name = str_replace("'","",$file_name);
$file_path = $upload_dir.$file_name;
$result = move_uploaded_file($temp_name, $file_path);
if($result)
{
echo "<b><font color=red>".$up_finish."</font></b><br><BR><BR>
";
}
else
{
echo "<b><font color=\"FF0000\">".$up_fail."</font></b><br>";
}
}
}
else echo "<i>$up_empty</i><br>\n";
}
}
include ('connect.php');
$query="INSERT INTO foto (foto,rubriek,actief)";
$query=$query. "VALUES ('";
$query=$query . $file_name."','";
$query=$query . $_POST["rubriek"]."','";
$query=$query . $_POST["actief"]."');";
$result=mysql_query($query) or die ("FOUT: ".mysql_error());
//echo ("De query is als volgt: <b>$query</b><hr>");
?>
$url_dir = "http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
$url_this = "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
$upload_url = $url_dir."/".$upload_dir."/";
if($_REQUEST[upload])
{
/************* Maak Upload Map *****************/
if (!is_dir("$upload_dir"))
{
if (!mkdir($upload_dir))
die ($upload_dir."map bestaat niet en het aanmaken is mislukt.");
if (!chmod($upload_dir,0777))
die ($upload_dir.", ".$up_perm.".");
}
/********** Begin Controle En Upload **************/
for($x = 0; $x < $aantal_u; $x++)
{
$upfile = 'upfile_'.$x;
$file_name = $_FILES[$upfile]['name'];
$file_type = $_FILES[$upfile]['type'];
$file_ext = strtolower(substr($file_name,strrpos($file_name,".")));
echo "<b>Upload ".($x+1).":</b> ";
if ($file_name != "" && $file_type != "")
{
if (!in_array($file_type, $file_mimes) && !in_array($file_ext, $file_exts))
{
echo "<b><font color=\"FF0000\">".$up_fail."</font></b><br>\n";
}
else
{
$temp_name = $_FILES[$upfile]['tmp_name'];
$file_name = $_FILES[$upfile]['name'];
$file_name = str_replace("\\","",$file_name);
$file_name = str_replace("'","",$file_name);
$file_path = $upload_dir.$file_name;
$result = move_uploaded_file($temp_name, $file_path);
if($result)
{
echo "<b><font color=red>".$up_finish."</font></b><br><BR><BR>
";
}
else
{
echo "<b><font color=\"FF0000\">".$up_fail."</font></b><br>";
}
}
}
else echo "<i>$up_empty</i><br>\n";
}
}
include ('connect.php');
$query="INSERT INTO foto (foto,rubriek,actief)";
$query=$query. "VALUES ('";
$query=$query . $file_name."','";
$query=$query . $_POST["rubriek"]."','";
$query=$query . $_POST["actief"]."');";
$result=mysql_query($query) or die ("FOUT: ".mysql_error());
//echo ("De query is als volgt: <b>$query</b><hr>");
?>
<form name="upload" method="post" action="upload_foto.php" enctype="multipart/form-data">
<input type=hidden value=ja name="actief" size=20>
<td id=vak4 class=body><font face=verdana size=2><B>Rubriek:</b></td><td id=vak4 class=body><select name=rubriek><option value=''><B>Rubriek keuze</B></option>");
Code (php)
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
<?php
include ('connect.php');
$result=mysql_query ("SELECT * FROM fotorubriek ORDER BY `rubriek`");
while ($rij=mysql_fetch_array ($result))
echo ("<option value=". $rij ["rubriek"].">". $rij ["rubriek"]."</option>");
mysql_close();
echo ("</select></td>");
?>
include ('connect.php');
$result=mysql_query ("SELECT * FROM fotorubriek ORDER BY `rubriek`");
while ($rij=mysql_fetch_array ($result))
echo ("<option value=". $rij ["rubriek"].">". $rij ["rubriek"]."</option>");
mysql_close();
echo ("</select></td>");
?>
<input type=hidden value=ja name="actief" size=20>
Code (php)
<TR><TD colspan=2 bgColor=98cb00><input type="submit" name="upload" class=formulier1 value="Upload" size="83"> </TR></TD>
</form>
</SPAN></B></TD></TR></FONT></TBODY></table>
zetten.
En verder is mooier en beter om er dit van te maken: