if have changed it, but it gives this problem if($_FILES['file']['name'] == "") { echo("<script language=\"javascript\">alert('U bent vergeten een file te selecteren');</script>"); }else{
it means that i have forgotten to select a file, so i did someting wrong in the script, can somebody see what´s wrong with te script?
changed script:
<?php
$gebruiker = "user";
$password = "password";
$database = "housing";
$toegestaan = array('jpg', 'gif', 'png', 'bmp');
$maxfilesize = 2;
$maxwidth = 10000;
$maxheight = 10000;
$directory = "uploads/";
$tabelnaam = "property";
include ("config.php");
if(isset($_POST['submit'])) {
if($_FILES['file']['name'] == "") { echo("<script language=\"javascript\">alert('U bent vergeten een file te selecteren');</script>"); }else{
$extensie = explode(".", $_FILES['file']['name']);
$extcount = count($toegestaan);
$extcount2 = count($toegestaan);
for ($x=0; $x<count($_FILES); $x++){
if(strtolower($extensie[1]) == $toegestaan[$x]) {
$extok = true;
$x = count($toegestaan);
}else{
$extok = false;
}
}
if($extok == false) {
echo("<script language=\"javascript\">alert('Deze extensie is niet geldig. Geldige extensies zijn:\n");
for ($x=0; $x<count($_FILES); $x++){
$extup = strtoupper($toegestaan[$b]);
if($x == $extcount - 1) {
echo("$extup");
}else{
echo("$extup, ");
}
}
echo("');</script>");
}else{
$filesize = $_FILES['file'][$x]['size'];
$filesize2 = ("".ROUND($filesize / 1024, 1)." KB");
if($filesize > 1024) { $filesize2 = ("".ROUND($filesize2 / 1024, 1)." MB"); }
if($filesize > 1073741824) { $filesize2 = ("".ROUND($filesize2 / 1024 / 1024 / 1024, 1)." GB"); }
$maxfilesize2 = $maxfilesize 1024 1024;
if($_FILES['file'][$x]['size'] > $maxfilesize2) {
echo("<script language=\"javascript\">alert('Dit bestand is te groot voor de upload\nToegstaan: $maxfilesize MB');</script>");
}else{
$filenaam = $FILES['file']['name'];
$filenaam1 = $FILES['file']['name'];
if(file_exists("$directory$filenaam")) {
echo("<script language=\"javascript\">alert('De bestandnaam ($filenaam) is al in gebruik');</script>");
}else{
$size = getimagesize($_FILES['file']['tmp_name']);
$width = $size[0];
$height = $size[1];
if($width > $maxwidth || $height > $maxheight) {
echo("<script language=\"javascript\">alert('Het formaat van dit bestand is niet correct.\nMag max zijn: $maxwidth x $maxheight');</script>");
}else{
$pad = $directory;
include("config.php");
if($SERVER['REQUEST_METHOD'] == "POST")
{
$insert = "INSERT INTO property (street, no, zip, city, status, type, area, available, tos, parking, kitchen, toilet, furnised, notes, filenaam, price, filenaam1) VALUES ('$POST[street]', '$POST[no]', '$POST[zip]', '$POST[city]', '$POST[status]', '$POST[type]', '$POST[area]', '$POST[available]', '$POST[tos]', '$POST[parking]', '$POST[kitchen]', '$POST[toilet]', '$POST[furnised]', '$POST[notes]', '$POST[filenaam]', '$POST[price]', '$POST[filenaam1]')";
mysql_query($insert) or die (mysql_error());
$property_id = mysql_insert_id();
if(isset($_POST['submit'])) {
$query = "UPDATE property
SET filenaam = '$pad$filenaam' WHERE property_id = $property_id";
$result = mysql_query($query);
copy($file, "$pad".$_FILES['file']['name']."");
echo("<center><font color=red>File uploaded...</font></center>");
}
}
}
}
}
}
}
echo "<b>De gegevens zijn succesvol toegevoegd in de database</b>";
require("toevoegen_property23.htm");
}
?>