Fehler in Uploadscript

Pascal Lattreuter

Grünschnabel
Hallo.
Habe ein Problem mit einem Uploadscript. Bei größeren Dateimengen (10-30 MB ca.) t der Upload nicht. Nach geraumer Zeit bricht es ohne eine Datei anzuzeigen einfach ab.

Hier der Code der upload.php

PHP:
<?php
	ini_set("max_execution_time", "1800");
	ini_set("max_input_time", "1800");
	ini_set("post_max_size", "128M");
	ini_set("memory_limit", "128M");


session_start();

	$_SESSION['name'] = $_GET['name']!= "" ? $_GET['name'] : $_SESSION['name'];



	if($_REQUEST['name'] != ""

		&& ($_SESSION['status'] == "Admin" || $_SESSION['status'] == "User")

		&& $_REQUEST['act'] == "Uploaden")

		{

		$_SESSION['upload'] = $_FILES;

		$fehler = "";

		for($i=0;$i<=4;$i++)

			{

			$_SESSION['upload']['file']['desc'][$i] = $_REQUEST['beschreibung_'.$i];

            if (file_exists($_FILES['file']['tmp_name'][$i]))

                {

                move_uploaded_file($_FILES['file']['tmp_name'][$i], "userdata/#temp/".$_FILES['file']['name'][$i]);

                if(substr($_FILES['file']['name'][$i], -3, 3) != "php"

                && substr($_FILES['file']['name'][$i], -3, 3) != "PHP")

                    {

                    if(file_exists("userdata/".$_SESSION['name']."/".$_FILES['file']['name'][$i]))

                    	{

                    	$fehler = "Datei schon vorhanden.";

                    	}

                    else

                    	{

                    	copy("userdata/#temp/".$_FILES['file']['name'][$i], "userdata/".$_SESSION['name']."/".$_FILES['file']['name'][$i]);

                    	unlink("userdata/#temp/".$_FILES['file']['name'][$i]);

						$tit = str_replace(".", "_", $_FILES['file']['name'][$i]);

						$fp = fopen("userdata/".$_SESSION['name']."/$tit".".des", "w+");

						fwrite($fp, "n#".$_SESSION['user']."~".$_SESSION['upload']['file']['desc'][$i]);

						fclose($fp);

						$des_name = str_replace(".", "_", $_FILES['file']['name'][$i]).".des";

$str = file_get_contents("userdata/".$_SESSION['name']."/".$des_name);

$beschreibung = substr($str, strpos($str, "~")+1);

$beschreibung = $beschreibung == "" ? "Keine Beschreibung angegeben" : $beschreibung;

$_SESSION['up_mail'] .= $_FILES['file']['name'][$i]." - ".$beschreibung."\n";

                    	}

                    }

                else

                    {

                    unlink("userdata/#temp/".$_FILES['file']['name'][$i]);

                    $fehler .= "Es dürfen keine php-Dateien hochgeladen werden.<br>\n";

                    }

                }

            elseif($_FILES['file']['name'][$i] != "")

            	{

            	$fehler .= "Der Upload ist fehlgeschlagen<br>\n";

            	}

			}

		if($fehler == "")

			{

			$tar = $_SESSION['status'] == "Admin" ? "adminintern.php" : "daten.php";

			$up_files = "mail";

			include $tar;

			}

		}



	if($_REQUEST['act'] == "Speichern")

		{

		$ok=0;

		for($i=0;$_REQUEST['file_'.$i] != "";$i++)

			{

			if($_REQUEST['way_'.$i] == "del")

				{

				unlink("userdata/#temp/".$_REQUEST['file_'.$i]);

				$ok++;

				}

			if($_REQUEST['way_'.$i] == "write")

				{

            	copy("userdata/#temp/".$_REQUEST['file_'.$i], 	"userdata/".$_SESSION['name']."/".$_REQUEST['file_'.$i]);

                unlink("userdata/#temp/".$_REQUEST['file_'.$i]);

				$tit = str_replace(".", "_", $_REQUEST['file_'.$i]);

				$fp = fopen("userdata/".$_SESSION['name']."/$tit".".des", "w+");

                fwrite($fp, "n#".$_SESSION['user']."~".$_SESSION['upload']['file']['desc'][$i]);

                fclose($fp);

                $des_name = str_replace(".", "_", $_REQUEST['file_'.$i]).".des";

				$str = file_get_contents("userdata/".$_SESSION['name']."/".$des_name);

				$beschreibung = substr($str, strpos($str, "~")+1);

				$beschreibung = $beschreibung == "" ? "Keine Beschreibung angegeben" : $beschreibung;

				$_SESSION['up_mail'] .= $_REQUEST['file_'.$i]." - ".$beschreibung."\n";

                $ok++;

				}

			if($_REQUEST['way_'.$i] == "rename" && $_REQUEST['new_name_'.$i] != "")

				{

				$end = substr($_REQUEST['file_'.$i], strpos($_REQUEST['file_'.$i], "."));

                if(file_exists("userdata/".$_SESSION['name']."/".$_REQUEST['new_name_'.$i].$end))

                    {

                    $fehler = "Datei schon vorhanden.";

                    }

                else

                    {

                    copy("userdata/#temp/".$_REQUEST['file_'.$i],   "userdata/".$_SESSION['name']."/".$_REQUEST['new_name_'.$i].$end);

                    unlink("userdata/#temp/".$_REQUEST['file_'.$i]);

                    $end = substr($_REQUEST['file_'.$i], strpos($_REQUEST['file_'.$i], "."));

					$tit = $_REQUEST['new_name_'.$i]."_".substr($end, 1);

					$fp = fopen("userdata/".$_SESSION['name']."/$tit".".des", "w+");

               		fwrite($fp, "n#".$_SESSION['user']."~".$_SESSION['upload']['file']['desc'][$i]);

               		fclose($fp);

               		$des_name = str_replace(".", "_", $_REQUEST['new_name_'.$i]).".des";

                    $str = file_get_contents("userdata/".$_SESSION['name']."/".$des_name);

                    $beschreibung = substr($str, strpos($str, "~")+1);

                    $beschreibung = $beschreibung == "" ? "Keine Beschreibung angegeben" : $beschreibung;

                    $_SESSION['up_mail'] .= $_REQUEST['new_name_'.$i]." - ".$beschreibung."\n";

                    }

                $ok++;

				}

			}

		if($i == $ok)

			{

			$tar = $_SESSION['status'] == "Admin" ? "adminintern.php" : "daten.php";

			$rest = "no";

			include $tar;

			}

		}



    if($up_files == "mail" || $rest == "no")

        {

        mysql_connect("localhost", "web2", "936L2MQQ");

		mysql_select_db("usr_web2_2");

        $sql = "SELECT Emailadr FROM Login WHERE User='".$_SESSION['name']."';";

        $result = mysql_query($sql);

        $User = mysql_fetch_assoc($result);

        $to = $User['Emailadr'];

        $am = date("j.n.Y");

        $um = date("G:i");

        $message = "Hallo ".$_SESSION['name'].",\n\n";

        $message .= "der Benutzer ".$_SESSION['user']." hat am $am um $um Uhr die folgenenden Dateien für Sie hinterlegt:

\n";

        $message .= $_SESSION['up_mail'];

        mail($to, "Dateien von ".$_SESSION['user']." erhalten!", $message, "From: info@lattreuter.de");

        $_SESSION['up_mail'] = "";

        $_SESSION['upload'] = "";

        die("");

        }



?>

<?php

//-----------------------------------------------------------------------------

// MySQL Verbindung

//-----------------------------------------------------------------------------

	@mysql_connect("localhost", "******", "*********************************")

		OR die("Die Verbindung zur Datenbank ist fehlgeschlagen!");

	@mysql_select_db("***********")

		OR die("Die Datenbank '************' konnte nicht geladen werden!");

//-----------------------------------------------------------------------------

?>

<?php

$abfrage = "SELECT * FROM Texte WHERE ID = 'Intern'";

$ergebnis = mysql_query($abfrage);

while($row = mysql_fetch_object($ergebnis))

   {

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head><link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon">



<link rel="stylesheet" type="text/css" href="style.css">

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<script src="menu.js" type="text/javascript"></script>





<title>Lattreuter GmbH - <?php echo "$row->Titel"; ?></title>


</head>

<body><a name="oben"></a>



<table align="center" cellpadding="0" cellspacing="0" id="gesamttabelle">



<tr><td class="header"></td></tr>



<tr><td class="karteikarten"><a href="index.php"><img alt="" border="0" src="images/top_home.jpg" onMouseOver="this.src='images/top_home_hover.jpg';" onMouseOut="this.src='images/top_home.jpg';"></a><a href="unternehmen.php"><img alt="" border="0" src="images/top_unternehmen.jpg" onMouseOver="this.src='images/top_unternehmen_hover.jpg';" onMouseOut="this.src='images/top_unternehmen.jpg';"></a><a href="internet.php"><img alt="" border="0" src="images/top_internet.jpg" onMouseOver="this.src='images/top_internet_hover.jpg';" onMouseOut="this.src='images/top_internet.jpg';"></a><a href="mediengestaltung.php"><img alt="" border="0" src="images/top_mediengestaltung.jpg" width="118" height="24" onMouseOver="this.src='images/top_mediengestaltung_hover.jpg';" onMouseOut="this.src='images/top_mediengestaltung.jpg';"></a><a href="druck.php"><img alt="" border="0" src="images/top_druck.jpg" onMouseOver="this.src='images/top_druck_hover.jpg';" onMouseOut="this.src='images/top_druck.jpg';"></a><a href="shops.php"><img alt="" border="0" src="images/top_shops_serviceactive.jpg" onMouseOver="this.src='images/top_shops_serviceactive_hover.jpg';" onMouseOut="this.src='images/top_shops_serviceactive.jpg';"></a><a href="service.php"><img alt="" border="0" src="images/top_service_active.jpg" onMouseOver="this.src='images/top_service_active.jpg';" onMouseOut="this.src='images/top_service_active.jpg';"></a>

</td></tr>



<tr><td valign="top" class="textteil">

<div class="menu">

  <ul>

    <li><a class="padding" href="datenhandlingservice.php" onmouseover="montre('smenu1');" onmouseout="cache('smenu1');">Datenhandling</a></li>



    <li><a class="padding" href="auftragsanfrage.php" onmouseover="montre('smenu2');" onmouseout="cache('smenu2');">Auftragsanfrage</a></li>



    <li><a class="padding" href="downloads.php" onmouseover="montre('smenu3');" onmouseout="cache('smenu3');">Downloads & Links</a></li>



    <li><a class="padding" href="intern.php" onmouseover="montre('smenu4');" onmouseout="cache('smenu4');">Internbereich</a>

     <ul id="smenu4" onmouseover="montre('smenu4');" onmouseout="cache('smenu4');">

        <li class="border3"><a class=asd href="intern.php">Login</a></li>

        <li class="border"><a class=asd href="register.php">Registrierung</a></li>

        <li class="border2"><a class=asd href="intern_infos.php">Infos & FAQ</a></li>

     </ul>

    </li>

  </ul>

</div>

<br><br>



<table width="100%" align="left" cellpadding="0" cellspacing="0">

<tr>



<?php } ?>



<td valign="top" class="spaltemitte">

<b>:: Internbereich - Upload</b><br>

<hr style="background-color: black;" size="1"><br>



F&uuml;llen Sie das Formular aus, um Dateien f&uuml;r <?php echo $_SESSION['name']; ?> zu uploaden.<br><br>

<?php

if($_REQUEST['act'] == "Uploaden")

	{

    $work = false;

    $handle = opendir("userdata/#temp");

    $i=0;

    echo "<form action=\"upload.php\" method=\"post\">\n";

    while (false !== ($file = readdir($handle)))

        {

        $show = $file != "." && $file != ".." && !preg_match("/^_/", $file) ? true : false;

        $my = false;

        for($j=0;$j<=4;$j++)

            {

            if($_SESSION['upload']['file']['name'][$j] == $file)

                {

                $my = true;

                $work = true;

                }

            }

        if($show && $my == true)

            {

            echo "<b>Die Datei $file Existiert bereits.</b><br>\n";

            $link = "userdata/".$_SESSION['name']."/".$file;

            $size = filesize($link) >= 1024 ? round((filesize($link)/1024), 0)." KB" : filesize($link)." B";

            $size = filesize($link) >= 1048576 ? round((filesize($link)/1048576), 0)." MB" : $size;

            echo "Server: <a href=\"$link\">".date("j.n.Y H:i", filectime($link))."</a> ($size)<br>";

            $link = "userdata/#temp/".$file;

            $size = filesize($link) >= 1024 ? round((filesize($link)/1024), 0)." KB" : filesize($link)." B";

            $size = filesize($link) >= 1048576 ? round((filesize($link)/1048576), 0)." MB" : $size;

            echo "Lokal: <a href=\"$link\">".date("j.n.Y H:i", filectime($link))."</a> ($size)<br>\n<br>";

            echo "<input type=\"hidden\" name=\"file_$i\" value=\"$file\">\n";

            echo "<input type=\"radio\" name=\"way_$i\" value=\"del\"> Neue Datei löschen<br>\n";

            echo "<input type=\"radio\" name=\"way_$i\" value=\"write\" checked> Überschreiben<br>\n";

            echo "<input type=\"radio\" name=\"way_$i\" value=\"rename\">";

            $end = substr($file, strpos($file, "."));

            echo "Die neue Datei umbenennen:<input type=\"text\" name=\"new_name_$i\">$end<br>\n<br>\n";

            $i++;

            }

        }

        echo "<input type=\"submit\" name=\"act\" value=\"Speichern\">\n";

        echo "</form>\n";

    closedir($handle);

    if($work == true)

        {

        echo "</body>\n";

        echo "</html>\n";

        die("");

        }

    echo $fehler;

	}

?>



<form enctype="multipart/form-data" action="upload.php" method="post">

<table border="0" cellspacing="0" cellpadding="0">

<tr>

<td height="35" width="125"><b>Benutzername:</b></td><td><input id=readonly type="text" value="<?php echo $_SESSION['name']; ?>" name="name" size="20" readonly id="style"></td>

</tr>

<tr>

<td width="125" height="35"><b>Datei 1:</b></td><td><input type="file" name="file[0]" size="30" class="eingabe"></td>

</tr>

<tr>

<td width="125" height="35" valign="top">Beschreibung:</td><td><textarea name="beschreibung_0" cols="0" rows="3" wrap="off"></textarea></td>

</tr>

<tr>

<td width="125" height="35"><b>Datei 2:</b></td><td><input name="file[1]" class="eingabe" type="file" size="30" </td>

</tr>

<tr>

<td width="125" height="35" valign="top">Beschreibung:</td><td><textarea cols="0" rows="3" name="beschreibung_1" wrap="off"></textarea></td>

</tr>

<tr>

<td width="125" height="35"><b>Datei 3:</b></td><td><input name="file[2]" class="eingabe" type="file" size="30" </td>

</tr>

<tr>

<td width="125" height="35" valign="top">Beschreibung:</td><td><textarea cols="0" rows="3" name="beschreibung_2" wrap="off"></textarea></td>

</tr>

<tr>

<td width="125" height="35"><b>Datei 4:</b></td><td><input name="file[3]" class="eingabe" type="file" size="30" </td>

<tr>

<td width="125" height="35" valign="top">Beschreibung:</td><td><textarea cols="0" rows="3" name="beschreibung_3" wrap="off"></textarea></td>

</tr>

<tr>

<td width="125" height="35"><b>Datei 5:</b></td><td><input name="file[4]" class="eingabe" type="file" size="30" </td>

</tr>

<tr>

<td width="125" height="35" valign="top">Beschreibung:</td><td><textarea cols="0" rows="3" name="beschreibung_4" wrap="off"></textarea></td>

</tr>

<tr>

<td height="35" width="125"></td><td><input type="reset" value="Zurücksetzen"><input name="act" type="submit" value="Uploaden"></td>

</tr>

</table>

<a href="intern.php"><b>Zur&uuml;ck</b></a>

</form>

</td>



<td valign="top" class="spalterechts">

<?php include 'spalte_rechts.php'; ?>

</td></tr>







<tr><td height="8"></td></tr>

<tr>

  <td align="center" valign="middle" class="footer">

<?php include 'footer.php'; ?>

</td>

</tr>



</table>



<br><br>  <div align="center"><a href="http://validator.w3.org/check?uri=referer"><img border=0 src="images/vhtml.png" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a> <a href="http://jigsaw.w3.org/css-validator/check/referer"><img style="border:0;width:88px;height:31px" src="images/vcss.png" alt="Valid CSS!"></a><br><a href="webcoding.php" style="font-size:10px;">Was bedeuten diese Symbole?</a></div><script type="text/javascript"><!--

var color = Math.pow(2,screen.pixelDepth);

var cookie = (navigator.cookieEnabled == true) ? "on" : "off";

var java = (navigator.javaEnabled() == true) ? "on" : "off";

document.write('<script src="http://www.traci.de/cgi-bin/uos/uos.cgi?id=lattreuter_gmbh&action=index&cookie=' + cookie + '&java=' + java + '&location=' + escape(document.location) + '&ref=' + escape(document.referrer) + '&ref2=' + escape(document.referrer) + '&farbe=' + color + '&bit=' + screen.colorDepth + '&width=' + screen.width + '&height=' + screen.height + '"><\/script>');

</script></body>

</html>


Also ne Datei mit exakt 8000 KB hat funktioniert.... Sachen darüber nicht...
 
Zurück