note 103654 added to features.file-upload

From: Date: Tue, 26 Apr 2011 16:00:32 +0000
Subject: note 103654 added to features.file-upload
Groups: php.notes 
Request: Send a blank email to php-notes+get-179167@lists.php.net to get a copy of this message
I wrote a little upload Manager, inspired by Marcus' post. I hope it helps ;) (Sorry for HTML-tags) <html><head><title>Simple Upload Manager</title></head><body> <form action="<?php $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data"> <input type="file" name="ufile" /> <input type="submit" value="Upload" /> <input type="hidden" name="upload" value="1" /> </form> <?php $uploaddir = "files/"; // upload directory //Enable this if you want to display PHP-Warnings ini_set('display_errors', 0 ); if($_POST['upload'] == 1) { $tempname = $_FILES['ufile']['tmp_name']; $name = $_FILES['ufile']['name']; $type = mime_content_type($tempname); $size = $_FILES['ufile']['size']; $path = $uploaddir.$name; copy($tempname, $path); ?> <table border="1" width="100%"> <colgroup><col width="*"><col width="20%"><col width="20%"></colgroup> <thead> <tr><th align="Center" colspan="3" bgcolor="green"><font color="white">Upload Successful</font></th></tr> <tr><th align="center"><b>Name</b></th><th align="center"><b>Size</b></th><th align="center"><b>MIME-Type</b></th></tr> </thead> <tbody><tr><td align="left"><?php echo $name; ?></td><td align="left"><?php echo $size; ?></td><td align="left"><?php echo $type; ?></td></tr></tbody> </table><?php } elseif($_GET['del'] != '') { if (!unlink($uploaddir.$_GET['del']))echo '<font color="#c00000">Error Deleting File</font>'; else echo '<font color="green">File deleted</font>'; }?> <table border="1" width="100%"> <colgroup><col width="*"><col width="20%"><col width="20%"></colgroup> <thead> <tr><th align="Center" colspan="4" bgcolor="black"><font color="white">Uploaded Files</font></th></tr> <tr><th align="center"><b>Name</b></th><th align="center"><b>Size</b></th><th align="center"><b>MIME-Type</b></th><th align="center"><b>&nbsp;</b></th></tr> </thead> <tbody> <?php if ($handle = opendir($uploaddir)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { echo '<tr';if($name == $file) echo ' class="current"'; echo '>'; echo '<td align="left">'.$file.' (<a href="'.$uploaddir.$file.'">'.$uploaddir.$file.'</a>)</td>'; echo '<td align="left">'.filesize($uploaddir.$file).'</td>'; echo '<td align="left">'.mime_content_type($uploaddir.$file).'</td>'; echo '<td align="center"><a href="'.$_SERVER['PHP_SELF'].'?del='.$file.'">Del</a></td>'; echo '</tr>'; } } closedir($handle); } ?> </tbody> </table> </body></html> ---- Server IP: 69.147.83.197 Probable Submitter: 92.224.66.197 ---- Manual Page -- http://www.php.net/manual/en/features.file-upload.php Edit -- https://master.php.net/note/edit/103654 Del: integrated -- https://master.php.net/note/delete/103654/integrated Del: useless -- https://master.php.net/note/delete/103654/useless Del: bad code -- https://master.php.net/note/delete/103654/bad+code Del: spam -- https://master.php.net/note/delete/103654/spam Del: non-english -- https://master.php.net/note/delete/103654/non-english Del: in docs -- https://master.php.net/note/delete/103654/in+docs Del: other reasons-- https://master.php.net/note/delete/103654 Reject -- https://master.php.net/note/reject/103654 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#179167) next »