Hallo,
Ik heb een html form waarbij gebruikers foto's kunnen uploaden. Helaas lukt het uploaden niet, hij komt steeds terug op dat het bestand ongeldig is...
Dit is de handler:
<?php
$allowedExts = array("jpg", "jpeg", "gif", "png");
$extension = end(explode(".", $_FILES["file"]["name"]));
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/png")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 20000)
&& in_array($extension, $allowedExts))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Error: " . $_FILES["file"]["error"] . "<br>";
}
else
{
$connection=mysql_connect ('localhost', '***', '***');
if (!$connection) {
die('Not connected : ' . mysql_error());
}
$db_selected = mysql_select_db('***', $connection);
if (!$db_selected) {
die ('Can\'t use db : ' . mysql_error());
}
$file = $_FILES['file'];
$name = $file['name'];
$path = "/home/***/domains/***.nl/public_html/data/fotos/" . basename($name);
if (move_uploaded_file($file['tmp_name'], $path)) {
// Move succeed.
$newpath = preg_replace('#/home/***/domains/***/public_html/artistone/#', 'http://***.nl/', $path);
$sql = "INSERT INTO fotoboek (url, titel, dataid) VALUES ('" . mysql_real_escape_string($newpath) . "', '" . $_POST['titel'] . "', '" . $_POST['dataid'] . "')";
$result = mysql_query($sql);
// echo "Opgeslagen en toegevoegd aan DB.";
header ('location: ../gallery.php?upload=ok');
} else {
// Move failed. Possible duplicate?
echo "ERROR: Dubbele file";
header ('location: ../addphoto.php?error=dubbel');
}
}
}
else
{
header ('location: ../addphoto.php?error=ongeldig');
}
?>
Kan iemand mij vertellen waarom hij t niet doet?
1.431 views