ich habe einen Problem mit meinem Bilderupload in der add.tpl. Ich glaube den verursacht die Datei ads_controller.php, bin mir aber nicht sicher und hoffe, dass jemand weiß, womit mein Fehler zusammenhängt. Ich habe leider in Google und im Forum nichts dergleichen gefunden und bin noch ein Neuling was PHP betrifft
Hier ist mein Formular mit der add.tpl mit dem Upload Code:
- Code: Alles auswählen
- <tr>
<td valign="top">Foto hinzufügen</td>
<td>
<input type="hidden" value="500000" name="max_file_size" />
<input type="file" style="width: 250px;" name="file" /><br/>
<font color="#888888">nur GIF-, JPG- und PNG-Bilder mit max. 200 KB</font>
</td>
</tr>
{if $settings_upload == "1"}
<tr>
<td valign="top">Weitere Anlage</td>
<td>
<input type="hidden" value="500000" name="max_file_size" />
<input type="file" style="width: 250px;" name="file2" /><br/>
<font color="#888888">nur PDF- und DOC-Dokumente mit max. 200 KB</font>
</td>
</tr>
{/if}
und hier die ads_controller.php
- Code: Alles auswählen
//MySQL inserts
if($_FILES['file']['tmp_name'])
{
switch ( $_FILES['file']['type'] )
{
case "image/gif":
$this->data['Ad']['img_type'] = "gif";
break;
case "image/jpeg":
$this->data['Ad']['img_type'] = "jpeg";
break;
case "image/png":
$this->data['Ad']['img_type'] = "png";
break;
case "image/jpg":
$this->data['Ad']['img_type'] = "jpg";
break;
default:
$this->data['Ad']['img_type'] = "";
break;
}//end switch
}//end if
if($_FILES['file2']['tmp_name'])
{
switch ( $_FILES['file2']['type'] )
{
case "application/msword":
$this->data['Ad']['data_type'] = "doc";
break;
case "application/pdf":
$this->data['Ad']['data_type'] = "pdf";
break;
default:
$this->data['Ad']['data_type'] = "";
break;
}//end switch
}//end if
$this->data['Ad']['startdate'] = date("d M Y", time());
$this->data['Ad']['content'] = strip_tags($this->data['Ad']['content']);//Kein HTML
$users_id = $_SESSION['mYpERsOnALhaSHkeY']['User']['id'];
$this->data['Ad']['user_id'] = $users_id;
$this->Ad->save($this->data['Ad']);
$last_id = $this->Ad->getLastInsertId();
//and file upload
$root = WWW_ROOT;
if($_FILES['file']['tmp_name'])
{
switch ( $_FILES['file']['type'] ){case "image/gif":
$this->gd_resize($_FILES['file']['tmp_name'], "gif", $last_id);
move_uploaded_file($_FILES['file']['tmp_name'], $root."upload/".$last_id."_full.gif");
// copy($root."upload/".$last_id."_full.gif", $root."upload/".$last_id.".gif");
chmod ($root."upload/".$last_id."_full.gif", 0755);
chmod ($root."upload/".$last_id.".gif", 0755);
break;
case "image/jpeg":
$this->gd_resize($_FILES['file']['tmp_name'], "jpeg", $last_id);
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");
copy($root."upload/".$last_id."_full.png", $root."upload/".$last_id.".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;
}
}
Aber wie gesagt, weiß ich nicht ob es an dieser liegt...Ich habe aber in keiner anderen Datei einen möglichen Hinweis gefunden. Ich hoffe sehr dass mir hier jemand helfen kann
Liebe Grüße
regi