I try to let the user upload an Image, but it doesn't work. No Error or anything, but the file doesnt appear in the folder.
$id = $rowcount + 1;
$pfad_imgfront = "bilder/front/";
$pfad_imgback = "bilder/back/";
//Fileupload
if ($_FILES['imgfront']['size'] > 0) {
$pfad_imgfront = $pfad_imgfront . basename($_FILES['imgfront']['name']);
$dateityp = pathinfo($pfad_imgfront, PATHINFO_EXTENSION);
if ($_FILES["imgfront"]["size"] > 2000000) {
echo "Ihr Bild ist grösser als 2MB.";
$uploadOk = 0;
}
if ($dateityp != "jpg" && $dateityp != "png" && $dateityp != "jpeg" && $dateityp != "gif" && $dateityp != "bmp") {
echo "Nur JPG, JPEG, PNG, BMP & GIF Dateien sind erlaubt.";
$uploadOk = 0;
}
if ($uploadOk == 0) {
echo "Sorry, your file was not uploaded.";
// if everything is ok, try to upload file
} else {
if (move_uploaded_file($_FILES["imgfront"]["tmp_name"], $pfad_imgfront)) {
rename($pfad_imgfront, $id . 'front');
} else {
echo "Sorry, there was an error uploading your file.";
}
}
}
The html Form that was requested by a user:
<form enctype="multipart/form-data" action="neu_aufgabe.php"
method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="2000000" />
Bild zur Aufgabe (max. 2MB): <input name="imgfront" type="file" /><br />
<input type="hidden" name="MAX_FILE_SIZE" value="2000000" />
Bild zur Lösung (max. 2MB): <input name="imgback" type="file" /><br />
<input type="submit" value="Senden" /> </form>
Any help is welcomed :D