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... Link to comment https://forums.phpfreaks.com/topic/59608-solved-random-new-lines/ 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. } Link to comment https://forums.phpfreaks.com/topic/59608-solved-random-new-lines/#findComment-296207 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.