Ich habe ein Problem mit meinem Bilderupload. Ich versuche mehrere Auswahlfelder in meinem Formular einzubauen und habe deshalb in meiner MySQL Datenbank mehrere Felder eingefügt, die ein Bild enthalten dürfen
(img1_type, img2_type, img3_type,img4_type und img_type).
Daraufhin habe ich dann meinen Code so angepasst (ads_controller.php):
PHP-Code:
//and file upload
$root = WWW_ROOT;
if($_FILES['file']['tmp_name'])
{
switch ( $_FILES['file']['type'] )
{
case "image/gif":
move_uploaded_file($_FILES['file']['tmp_name'], $root."upload/".$last_id.".gif");
chmod ($root."upload/".$last_id.".gif", 0755);
break;
case "image/jpeg":
move_uploaded_file($_FILES['file']['tmp_name'], $root."upload/".$last_id."_full.jpeg");
chmod ($root."upload/".$last_id.".jpeg", 0755);
chmod ($root."upload/".$last_id."_full.jpeg", 0755);
break;
case "image/png":
move_uploaded_file($_FILES['file']['tmp_name'], $root."upload/".$last_id."_full.png");
chmod ($root."upload/".$last_id."_full.png", 0755);
chmod ($root."upload/".$last_id.".png", 0755);
break;
default:
$this->set("error","2"); //File not allowed
break;
}
}
if(isset($_FILES['file2']['tmp_name']))
{
switch ( $_FILES['file2']['type'] )
{
case "application/msword":
move_uploaded_file($_FILES['file2']['tmp_name'], $root."upload/".$last_id.".doc");
chmod ($root."upload/".$last_id.".doc", 0755);
break;
case "application/pdf":
move_uploaded_file($_FILES['file2']['tmp_name'], $root."upload/".$last_id.".pdf");
chmod ($root."upload/".$last_id.".pdf", 0755);
break;
default:
$this->set("error","2"); //File not allowed
break;
}
}
if(isset($_FILES['file3']['tmp_name']))
{
switch ( $_FILES['file3']['type'] )
{
case "image/jpg":
move_uploaded_file($_FILES['file3']['tmp_name'], $root."upload/".$last_id.".jpg");
chmod ($root."upload/".$last_id.".jpg", 0755);
break;
case "image/gif":
move_uploaded_file($_FILES['file3']['tmp_name'], $root."upload/".$last_id.".gif");
chmod ($root."upload/".$last_id.".gif", 0755);
break;
case "image/png":
move_uploaded_file($_FILES['file']['tmp_name'], $root."upload/".$last_id."_full.png");
chmod ($root."upload/".$last_id."_full.png", 0755);
chmod ($root."upload/".$last_id.".png", 0755);
break;
default:
$this->set("error","2"); //File not allowed
break;
}
}
Code:
<form method="post" enctype="multipart/form-data" name="form" action="{$html->url('/ads/add')}"/> <input type="hidden" value="500000" name="max_file_size" /> <input type="file" style="width: 250px;" name="file" /><br/> <input type="hidden" value="500000" name="max_file_size" /> <input type="file" style="width: 250px;" name="file3" /><br/> <input type="hidden" value="500000" name="max_file_size" /> <input type="file" style="width: 250px;" name="file4" /><br/> <font color="#888888">nur GIF-, JPG- und PNG-Bilder mit max. 200 KB</font>
Was stimmt hier nicht? Habe ich etwas übersehen? Leider konnte ich im Forum und in Google nichts finden, oder hab einfch falsch gesucht -.-
Ich hoffe jemand kann mir hier helfen...
Liebe Grüße
regi
Einen Kommentar schreiben: