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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.