Jump to content

[SOLVED] Random new lines


Asday

Recommended Posts

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

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.
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.