php.de

Zurück   php.de > Webentwicklung > PHP Einsteiger > PHP Tipps 2005

 
 
LinkBack Themen-Optionen Thema bewerten
Alt 31.01.2005, 13:17  
Gast
 
Beiträge: n/a
Standard Smarty einbinden

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'] != && !$_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'] == || 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>
 
Sponsor Mitteilung
PHP Code Flüsterer

Registriert seit: 21.08.2005
Beiträge: 4682
PHP-Kenntnisse:
Fortgeschritten

Alt 31.01.2005, 13:19  
Erfahrener Benutzer
 
Registriert seit: 14.01.2004
Beiträge: 2.543
fantast
fantast eine Nachricht über ICQ schicken
Standard

wir sind nich das smarty-support-forum.

aber zu deiner frage:
<?php include("dateiname"); ?>
__________________
Was ist validität?
fantast ist offline  
Alt 31.01.2005, 13:29  
Gast
 
Beiträge: n/a
Standard

Geht nicht.

Es wird gar nix angezeigt.

Ich habe das <?php include("upload.tpl"); ?>
an die rot markierte Stelle bildupload gesetzt.
 
Alt 31.01.2005, 13:32  
Erfahrener Benutzer
 
Registriert seit: 14.01.2004
Beiträge: 2.543
fantast
fantast eine Nachricht über ICQ schicken
Standard

ist php ueberhaupt aktiviert und eingebunden ?

mach mal ne neue datei und schreib da nichts weiter als <?php phpinfo(); ?> rein. die speicherst du dann und rufst sie auf. und dann poste mal, was da als output kommt...
__________________
Was ist validität?
fantast ist offline  
Alt 31.01.2005, 13:38  
Gast
 
Beiträge: n/a
Standard

Zitat:
Zitat von tom95
Ich habe das <?php include("upload.tpl"); ?>
an die rot markierte Stelle bildupload gesetzt.
Du willst ja auch an der Stelle die upload.php einbinden!
 
Alt 31.01.2005, 13:42  
Gast
 
Beiträge: n/a
Standard

handbuch lesen soll helfen
http://smarty.php.net/manual/en/lang...nclude.php.php
 
Alt 31.01.2005, 13:46  
Gast
 
Beiträge: n/a
Standard

handbuch in deutsch lesen ist manchmal einfacher
http://smarty.php.net/manual/de/lang...nclude.php.php
 
Alt 31.01.2005, 13:55  
Gast
 
Beiträge: n/a
Standard

Ich habe jetzt versucht es so einzubinden

<tr>
<td><h1>Bild hochladen</h1></td>
<td></td>
</tr>

<tr>
<td>{include_php file="upload.php"}</td>
<td></td>
</tr>

bloß jetzt bekomme ich eine fehlerrmeldung
Fatal error: Cannot redeclare class smarty in C:\Server\Webs\OLM\Smarty\Smarty.class.php on line 74
 
Alt 31.01.2005, 14:39  
Gast
 
Beiträge: n/a
Standard

und warum schreibst du nicht <?php include("upload.php"); ?>, wie vorgeschlagen sondern nimmst eine lösung zu der dir niemand hier geraten hat?
 
Alt 31.01.2005, 16:09  
Gast
 
Beiträge: n/a
Standard

weil das smarty so nicht versteht ,....

sondern wenn Du da php schreiben willst musst das so machen im tpl-file

{php}

include("upload.php");

{/php}
 
 


Themen-Optionen
Thema bewerten
Thema bewerten:

Forumregeln
Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are an
Gehe zu

Ähnliche Themen
Thema Autor Forum Antworten Letzter Beitrag
Smarty + MySQL = immer falsche Ausgabe m0use` PHP Tipps 2006 44 21.11.2008 20:30
Smarty: Templatedateien werden nicht aktualisiert! DER_Brain PHP Tipps 2008 9 24.04.2008 22:40
Was ist Aufgabe des Templates (Smarty), was nicht? agrajag PHP Tipps 2007 8 24.02.2007 13:19
Smarty => 1ste allgemeine Verunsicherung Canni PHP Tipps 2006 7 10.10.2006 17:56
Smarty + Oop Problem Komandar PHP Tipps 2006 5 25.07.2006 14:36
problem mit javascript und smarty snatch-ic HTML, Usability und Barrierefreiheit 2 08.06.2006 22:11
Smarty verschachtelt snatch-ic PHP Tipps 2006 16 28.02.2006 20:54
[Erledigt] Navigation auf Smarty umstellen?! PHP-Fortgeschrittene 3 10.01.2006 09:19
Smarty installiert und nun? Cyrus PHP Tipps 2005-2 5 28.10.2005 16:14
Frage zu Smarty PHP Tipps 2005-2 10 07.07.2005 14:49
Smarty Error Simon9990 PHP Tipps 2005-2 8 07.07.2005 09:34
Smarty und X-Cart Profis gesucht Beitragsarchiv 1 21.05.2005 13:38
[Erledigt] includepathproblem pear blockiert smarty und umgekehrt PHP Tipps 2005 1 08.05.2005 18:46
Smarty? Die wesentlichen Vorteile? Off-Topic Diskussionen 7 20.09.2004 13:04
was ist schneller smarty, oder normaler php code? eQuin PHP-Fortgeschrittene 2 03.09.2004 11:51

Besucher kamen über folgende Suchanfragen bei Google auf diese Seite
smarty einbinden php, smarty einbinden, smarty in php einbinden, smarty bilder upload, x cart change $max_image_width, smarty _files[\'probe\'], php-datei einbinden smarty, bild mit smarty hochladen, smarty in_array php einbinden, smarty bild einbinden, smarty php includieren fatal error: cannot redeclare class smarty, fatal error: cannot redeclare class smarty_data in, cannot redeclare class smarty data

Alle Zeitangaben in WEZ +2. Es ist jetzt 06:02 Uhr.




Powered by vBulletin® Version 3.7.2 (Deutsch)
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
Aprilia-Forum, Aquaristik-Forum, Liebeskummer-Forum, Zierfisch-Forum, Geizkragen-Forum

Creative Commons License
Dieser Inhalt ist unter einer Creative Commons-Lizenz lizenziert.