Hallo,
folgendes: Ich habe ein Upload-Script das auch problemlos funktioniert, nur muss ich etwas verändern da es so einfach nicht gut geregelt ist, vor allem wenn mehrere Leute auf das Script uploaden...!
Hier ein kleiner Screenshot:

Ihr seht hier das alle Datein in der Liste angezeigt werden, die ebein draufgeladen wurden.
Ich hätte es aber gerne so, das ich diese Liste begrenzen würde das zum Beispiel nur noch die letzten 4 angezeigt werden.
Natürlich wäre es mir noch lieber wenn diese Liste ganz weg kommt und direkt nach dem Upload der Link zum Bild oder zur Datei angezeigt wird, aber das wird wohl schwerer zu realisieren sein...!
Achja.... der Code der Datei...
Ich hoffe es kann mir irgendwer helfen! 
MfG, TT-Leser
folgendes: Ich habe ein Upload-Script das auch problemlos funktioniert, nur muss ich etwas verändern da es so einfach nicht gut geregelt ist, vor allem wenn mehrere Leute auf das Script uploaden...!

Hier ein kleiner Screenshot:

Ihr seht hier das alle Datein in der Liste angezeigt werden, die ebein draufgeladen wurden.
Ich hätte es aber gerne so, das ich diese Liste begrenzen würde das zum Beispiel nur noch die letzten 4 angezeigt werden.
Natürlich wäre es mir noch lieber wenn diese Liste ganz weg kommt und direkt nach dem Upload der Link zum Bild oder zur Datei angezeigt wird, aber das wird wohl schwerer zu realisieren sein...!

Achja.... der Code der Datei...
Code:
<?php //Username + password $user = "*zensiert*"; $pass = "*zensiert*"; //Show the number of files to upload $files_to_upload = 1; //Directory where the uploaded files have to come //RECOMMENDED TO SET ANOTHER DIRECTORY THEN THE DIRECTORY WHERE THIS SCRIPT IS IN!! $upload_dir = "/home/www/nc0606/html/image/"; // -------------------------------- // // UPDATE LOG // // -------------------------------- // // Version 1.0 -> version 1.1 // - Confirm the deletion of the file // - Download a file (handy for PHP files ;)) // - Set the number of files to upload // - Don't show directory's // // Version 1.1 -> version 1.11 // - Able to rename the files // // Version 1.11 -> version 1.12 (09/05/04) // - Another download method // - Solved a bug // -------------------------------- // // -------------------------------- // // SCRIPT UNDER THIS LINE! // // -------------------------------- // session_start(); //When REGISTERED_GLOBALS are off in php.ini $_POST = $HTTP_POST_VARS; $_GET = $HTTP_GET_VARS; $_SESSION = $HTTP_SESSION_VARS; //When logging in, check username and password if($_GET['method'] == "login") { if($_POST['username'] == $user && $_POST['password'] == $pass) { //Set the session for logged in to true session_register('logged_in'); $_SESSION['logged_in'] = true; Header("Location: " . $_SERVER['PHP_SELF'] . ""); } } //Any other action the user must be logged in! elseif($_GET['method']) { //When not logged in, the user will be notified with a message if(!session_is_registered('logged_in')) { not_allowed(); exit; } session_register('message'); //Upload the file if($_GET['method'] == "upload") { $file_array = $HTTP_POST_FILES['file']; $_SESSION['message'] = ""; $uploads = false; for($i = 0 ; $i < $files_to_upload; $i++) { if($_FILES['file']['name'][$i]) { $uploads = true; if($_FILES['file']['name'][$i]) { $file_to_upload = $upload_dir."/".$_FILES['file']['name'][$i]; move_uploaded_file($_FILES['file']['tmp_name'][$i],$file_to_upload); chmod($file_to_upload,0777); $_SESSION['message'] .= $_FILES['file']['name'][$i]." uploaded. "; } } } if(!$uploads) $_SESSION['message'] = "No files selected!"; } //Logout elseif($_GET['method'] == "logout") { session_destroy(); } //Delete the file elseif($_GET['method'] == "delete" && $_GET['file']) { if(!@unlink($upload_dir."/".$_GET['file'])) $_SESSION['message'] = "File not found!"; else $_SESSION['message'] = $_GET['file'] . " deleted"; } //Download a file elseif($_GET['method'] == "download" && $_GET['file']) { $file = $upload_dir . "/" . $_GET['file']; $filename .= basename( $file ); $f = fopen( $file, "r" ); $content_len = (int) filesize($file); $content_file = fread( $f, $content_len ); fclose( $f ); $output_file = $filename; @ob_end_clean(); @ini_set('zlib.output_compression', 'Off'); header('Pragma: public'); header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1 header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1 header('Content-Transfer-Encoding: none'); header('Content-Type: application/octetstream; name="' . $output_file . '"'); //This should work for IE & Opera header('Content-Type: application/octet-stream; name="' . $output_file . '"'); //This should work for the rest header('Content-Disposition: inline; filename="' . $output_file . '"'); header("Content-length: $content_len"); echo $content_file; exit; } //Rename a file elseif( $_GET['method'] == "rename" ) { rename( $upload_dir . "/" . $_GET['file'] , $upload_dir . "/" . $_GET['to'] ); $_SESSION['message'] = "Renamed " . $_GET['file'] . " to " . $_GET['to']; } //Redirect to the script again Header("Location: " . $_SERVER['PHP_SELF'] ); } //HTML STARTING ?> <html> <head> <title>FileUpload version 1.12</title> <link href="style.css" type=text/css rel=Stylesheet> </head> <body> <table class='maintable' cellspacing=0 cellpadding=0 width=640 align='center'> <?php //Show logout link when logged in if(session_is_registered('logged_in')) { ?> <tr> <td class='actions'>?method=logout'>Logout</td> </tr> <?php } //Else the login screen else { ?> <tr> <td class='actions'>Please login for file upload.</td> </tr> <?php } ?> <tr> <td class='login'> <table class='logintable' cellspacing=2 cellpadding=2 align='center'> <tr> <td> <table cellspacing=2 cellpadding=2 align='center'> <tr> <td> <?php //When logged in, show the files in the uploaded dir. if(!session_is_registered('logged_in')) { ?> <form name='form' action='<?=$_SERVER['PHP_SELF'];?>?method=login' method='post'> <table class='logintable' cellspacing=2 cellpadding=2 align='center'> <td> <table cellspacing=2 cellpadding=2 align='center'> <tr> <td class='login' width=40>Username:</td> <td class='login'><input type='text' name='username'></td> </tr> <tr> <td class='login'>Password:</td> <td class='login'><input type='password' name='password'></td> </tr> </table> </td> </tr> <tr> <td colspan=2 align='center'><input type='submit' value='login'></td> </tr> </table> </form> <?php } else { ?> <table width=350> <tr> <?php //When there is a message, after an action, show it if(session_is_registered('message')) { echo "<td colspan=5 class='header' align='center'><font color='red'>" . $_SESSION['message'] . "</font></td></tr><tr>"; } ?> <td colspan=4 class='header' width=300>File</td> <td class='header' width=70>Size</td></tr> <?php //Handle for the directory $handle = @opendir($upload_dir); //Walk the directory for the files while($entry = readdir($handle)) { if($entry != ".." && $entry != "." && !is_dir($entry)) { //Set the filesize type (bytes, KiloBytes of MegaBytes) $filesize = filesize($upload_dir . "/" . $entry); $type = Array ('b', 'KB', 'MB'); for ($i = 0; $filesize > 1024; $i++) $filesize /= 1024; $filesize = round ($filesize, 2)." $type[$i]"; ?> <tr> <td></td> <td>?method=download&file=<?=$entry;?>'>[img]dl.gif[/img]' border=0></td> <td>[img]edit.gif[/img]' border=0></td> <td class='filenfo' width=300><?=$entry;?></td> <td class='filenfo' width=70><?=$filesize;?></td> </tr> <?php } } ?> <tr> <td class='filenfo' colspan=5> Upload a file.</td> </tr> <form method='post' enctype='multipart/form-data' action='<?=$_SERVER['PHP_SELF'];?>?method=upload'> <?php for( $i = 0; $i < $files_to_upload; $i++ ) { ?> <tr> <td colspan=5><input type='file' name='file[]' style='width: 100%'></td> </tr> <?php } ?> <tr> <td colspan=4 align='center'><input type='submit' value='Upload'></td> </tr> </form> </table> <?php } ?> </td> </tr> </table> </td> </tr> </table> </td> </tr> <tr> <td class='sign'>FileUpload version 1.12 Written by My-PHP</td> </tr> </table> </body> </html> <?php exit; function not_allowed() { echo "Action not permitted. Need to login first?"; } ?>

MfG, TT-Leser
Kommentar