Original geschrieben von TobiaZ
... meikel hilft dir sicher dabei...
... meikel hilft dir sicher dabei...
OffTopic:
Huch? Nachhilfe ist bei dem üblichen Dozentenhonorar von 25 EUR/h nicht mit enthalten....![]()
$test = str_replace ("\r\n", "\n", $test);
$test = str_replace ("\r", "\n", $test);
<?
if (isset($_POST['senden'])) {
echo $_FILES['file']['name']."<br>";
$explode = explode(".",$_FILES['file']['name']);
$count = count($explode);
$count--;
echo $count."<br>";
echo $explode[$count]."<br><br>";
$test = "jpg
jpeg
bmp
rar
zip
txt";
$test = str_replace ("\r\n", "\n", $test);
$test = str_replace ("\r", "\n", $test);
$test = explode("\n",$test);
$count_test = count($test);
$ok = "nein";
for($i=0;$i < $count_test;$i++){
$a = $explode[$count];
$b = $test[$i];
echo $a."<br>";
echo $b."<br><br>";
if($b == $a) {
$ok = "ja";
echo "if ist ausgeführt";
}
}
echo $ok;
} else {
?>
<html>
<body bgcolor=#FFFFFF text=#000000 link=#ccff88 vlink=ccff88 alink=#ccff88>
<form action="<?php $PHP_SELF; ?>"method="post" enctype="multipart/form-data">
<p>Bitte Datei auswählen:<br>
<input type=file name=file>
<p><button name="senden" type="submit">Hochladen</button>
</form>
</body>
</html>
<?
}
?>
<?
if (isset($_POST['senden'])) {
echo $_FILES['file']['name']."<br>";
$explode = explode(".",$_FILES['file']['name']);
$count = count($explode);
$count--;
echo $count."<br>"; // Kommt 1 raus weil ja nur ein punkt da ist
echo $explode[$count]."<br><br>"; // Da kommt in diesem fall txt raus
$test = "jpg
jpeg
bmp
rar
zip
txt";
$test = str_replace ("\r\n", "\n", $test);
$test = str_replace ("\r", "\n", $test);
$test = explode("\n",$test);
$count_test = count($test);
$ok = "nein";
for($i=0;$i < $count_test;$i++){
$a = $explode[$count];
$b = $test[$i];
echo $a."<br>"; // da kommt auch (in diesem fall) txt raus
echo $b."<br><br>"; // da kommt imma was anderes raus siehe oben $test
if($b == $a) {
$ok = "ja";
echo "if ist ausgeführt"; // Müsste eientlich einmal auftauchen weil $a(txt) ja einmal gleich is wie $b (das letzte von $test
}
}
echo $ok; // Kommt imma nur nein raus....
} else {
?>
<html>
<body bgcolor=#FFFFFF text=#000000 link=#ccff88 vlink=ccff88 alink=#ccff88>
<form action="<?php $PHP_SELF; ?>"method="post" enctype="multipart/form-data">
<p>Bitte Datei auswählen:<br>
<input type=file name=file>
<p><button name="senden" type="submit">Hochladen</button>
</form>
</body>
</html>
<?
}
?>
$ext = array_pop (explode('.', $dateiname));
$test = "jpg
jpeg
bmp
rar
zip
txt";
if (in_array( $extension, $test))
{
# her mit dem File
}
else
{
# hau ab damit!
}
<?php
$cfg['ort'] = "hierorts";
$cfg['user'] = "DAU";
$cfg['pass'] = "0815";
$cfg['db'] = "meine";
$filename = './config.inc.php';
if (!is_writable('./')) die ('<b>Error: darf nicht ins Verzeichnis schreiben</b>');
if (!$fp = fopen($filename,"w")) die ("<b>Error: darf $filename nicht schreiben</b>");
$conf = '<'.'?php'."\n";
foreach ($cfg as $key => $val)
{
$conf .= '$cfg[\''.$key."']=$val;\n"; # Die Zeile wird im Forum nicht korrekt dargestellt.
}
$conf .= '?'.'>';
fwrite($fp,$conf,strlen($conf));
fclose($fp);
Kommentar