Frage.
Wie kann ich an dieser Stelle wo bildupload steht:
upload.tpl PHP-Code:
<tr>
<td><h1>Bild hochladen</h1></td>
<td></td>
</tr>
<tr>
<td>[color=red]bildupload[/color]</td>
<td></td>
</tr>
diese komplette php-Datei einbinden ?
upload.php PHP-Code:
<?php
include("libTemplate.php");
// in diese datei werden die bilder gespeichert
$upload_dir = "uploaded_files";
// maximale Dateigröße in KB:
$max_file_size = 200;
// maximale Größe bei Bildern:
$max_image_width = 1024;
$max_image_height = 768;
// Datei-Typen:
$accepted_file_types = array('image/jpeg','image/pjpeg','image/gif','image/png','text/plain','text/html');
// Datei-Endungen:
$accepted_file_extensiones = array('jpg','jpeg','gif','png','txt','html','htm');
// Sprache:
$data = array();
$data['upload_subm_button'] = 'OK - Hochladen';
$data['error_headline'] = 'Fehler:';
$data['invalid_file_type'] = 'ungültiges Dateiformat ([file_type])';
$data['invalid_file_extension'] = 'ungültige Datei-Erweiterung ([file_extension])';
$data['file_too_large'] = 'Datei zu groß ([size] KB)';
$data['image_too_large'] = 'Bild zu groß ([width] x [height])';
$data['file_already_exists'] = 'die Datei [b][file][/b] existiert bereits';
$data['upload_successful'] = 'Die Datei [file] wurde erfolgreich hochgeladen!';
$data['upload_not_successful'] = '[b]Fehler:[/b] Die Datei [file] konnte nicht gespeichert werden!';
$data['load_up_another_file'] = "eine weitere Datei hochladen...";
?><html>
<head>
<title></title>
<style type="text/css">
<!--
body { font-family: Verdana,Arial,Helvetica,sans-serif; color: #000000; font-size:13px; background-color: body bgcolor="#FFFFCC">; margin: 0px; padding: 20px; }
h1 { margin: 0px 0px 20px 0px; font-size:18px; font-weight:bold; }
.caution { color: red; font-weight: bold; }
.small { font-size: 11px; }
-->
</style>
</head>
<body>
<?php
if (isset($_FILES['probe']) && $_FILES['probe']['size'] != 0 && !$_FILES['probe']['error'])
{
unset($errors);
// file type ok?
if (!in_array($_FILES['probe']['type'], $accepted_file_types)) $errors[] = str_replace("[file_type]",$_FILES['probe']['type'],$data['invalid_file_type']);
// extension ok?
$exts = explode(".", basename($_FILES['probe']['name']));
$file_extension = strtolower($exts[sizeof($exts)-1]);
if (!in_array($file_extension, $accepted_file_extensiones)) $errors[] = str_replace("[file_extension]",$file_extension,$data['invalid_file_extension']);
// file size ok?
if ($_FILES['probe']['size'] > $max_file_size*1000) $errors[] = str_replace("[size]",number_format($_FILES['probe']['size']/1000,0,",",""),$data['file_too_large']);
// if it's an image, image size ok?
if (in_array($_FILES['probe']['type'], $accepted_file_types) && in_array($_FILES['probe']['type'],array('image/jpeg','image/pjpeg','image/gif','image/png','image/bmp')))
{
$image_info = getimagesize($_FILES['probe']['tmp_name']);
if ($image_info[0] > $max_image_width || $image_info[1] > $max_image_width) { $data['image_too_large'] = str_replace("[width]",$image_info[0],$data['image_too_large']); $errors[] = str_replace("[height]",$image_info[1],$data['image_too_large']); }
}
// existiert der Dateiname bereits ?
if (file_exists($upload_dir."/".basename($_FILES['probe']['name']))) $errors[] = str_replace('[file]',$_FILES['probe']['name'],$data['file_already_exists']);
// Ist alles ok lade die Datei hoch
if (empty($errors))
{
if (move_uploaded_file($_FILES['probe']['tmp_name'], $upload_dir.'/'.basename($_FILES['probe']['name'])))
{
chmod($upload_dir.'/'.$_FILES['probe']['name'], 0644);
?>
<?php echo str_replace('[file]', '[url='.$upload_dir.']'.$_FILES['probe']['name'].'[/url]',$data['upload_successful']); ?></p>
<p class="small">[url="<?php echo basename($_SERVER['PHP_SELF']); ?>"]<?php echo $data['load_up_another_file']; ?>[/url]</p><?php
}
else
{
?>
<?php echo str_replace('[file]', $_FILES['probe']['name'],$data['upload_not_successful']); ?></p><?php
}
}
// ...else show what's wrong:
else
{
?><p class="caution"><?php echo $data['error_headline']; ?></p><ul><?php foreach($errors as $f) { ?>[*]<?php echo $f; ?><?php } ?>[/list]<?php
}
}
// show the upload form:
if (empty($_FILES['probe']) || $_FILES['probe']['size'] == 0 || isset($errors))
{
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
<input type="file" name="probe" />
<input type="submit" name="submit-button" value="<?php echo $data['upload_subm_button']; ?>">
</form>
<?php
}
$libTemplate->assign("profildaten",$data);
$libTemplate->display("upload.tpl");
//echo "<pre>".print_r($data,true)."</pre>";
?>
</body>
</html>