Asday Posted July 12, 2007 Share Posted July 12, 2007 This code: <?php // chdir(".."); ob_start(); $dir=opendir("upload"); echo '<table border="3">'; echo '<tr>'; echo '<td>Name </td><td>Open </td><td>Delete</td>'; echo '</tr>'; while(($file=readdir($dir)) !== false) { echo '<tr>'; echo '<td>' . $file . '</td>'; echo '<td>' . ' <a href="http://localhost/upload/' . $file . '">[Open]</a>' . '</td>'; echo '<td>' . ' <a href="?delfile=' . $file . '">[Delete]</a>' . '</td>'; echo '</tr>'; echo "<br />"; } echo '</table>'; if (isset($_GET["delfile"])) { unlink("upload/" . $_GET["delfile"]); header("Location: " . $_SERVER["PHP_SELF"]); exit; } ?> <br /><br /> <form action="uploadFile.php" method="post" enctype="multipart/form-data"> <label for="file">Filename:</label> <input type="file" name="file" id="file" /> <input type="submit" name="submit" value="Submit!" /> </form> <?php echo '<br /><br /><g194 style="font-size:65%">After uploading a file, you will need to refresh your browser for the file to show in the list. You will need to do this once per file.</g194>'; ?> <?php /*chdir(".."); print_r(scandir("upload"));*/ ?> Outputs several blank lines before doing what it's menat to. Why? (Thanks) EDIT: The moar files there are, the more blank lines there are... Quote Link to comment Share on other sites More sharing options...
Asday Posted July 12, 2007 Author Share Posted July 12, 2007 Nevermind, fixed it! while(($file=readdir($dir)) !== false) { echo '<tr>'; echo '<td>' . $file . '</td>'; echo '<td>' . ' <a href="http://localhost/upload/' . $file . '">[Open]</a>' . '</td>'; echo '<td>' . ' <a href="?delfile=' . $file . '">[Delete]</a>' . '</td>'; echo '</tr>'; //echo "<br />"; -- This bit was causing the trouble. } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.