Jump to content


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


Reading a large text file

Recommended Posts

Hi, I have a script that phases a chat log from a IM program to HTML, but when the chat log is bigger then 100KB (I think) it doesn't display a thing. Anything lower works perfectly.
Here's the code:
[code] $pext = getFileExtension($log_name);
$pext = strtolower($pext);

if ($pext != "txr") {
die("Bad file type, please upload a Log file (.txr only).");
} else {
        $handle = fopen($log, "r");
$contents = '';
if($handle) {
while (!feof($handle)) {
$contents .= fread($handle, filesize($log));
echo fix($contents);
Upload HTML:
[code]<form method="post" enctype="multipart/form-data" action="<? echo $PHP_SELF ?>">
  Log file (.txr):
  <input type="file" name="log" size="30" />
  <input type="hidden" name="action" value="1">
  <br />
  <br />
  <input type="submit" value="View Log">

Share this post

Link to post
Share on other sites
Have you tried just dumping the contents of the file into a variable with file_get_contents() ?
I can't see why it should fail on files over 100k - How long is it taking to execute?

Share this post

Link to post
Share on other sites


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.