Solved

Stream content of a file to php website

Posted on 2008-06-11
2
188 Views
Last Modified: 2010-04-21
We have a realtime application that writes lines to a text file (or to a fifo file, depending on how the file is created). Is it possible to display in realtime the content of this file with php or something else in a website? We don't want the user to have to press F5 every second to see what has been added to the file, it should be displayed automatically.
0
Comment
Question by:Commsquare
2 Comments
 
LVL 48

Accepted Solution

by:
hernst42 earned 500 total points
ID: 21759783
If you have a pipe you can try this, but only one user will then be able to read the data. For using normal files this will get more complicated you you need to count the lines and then start again reading the file again.
while(1) {

  $text = file_get_contents('/path/to/log/pipe');

  echo $text;

  echo '<script>window.scrollTo(0, 10000000);</script>' ."\n";

  flush();

  sleep(2);

}

Open in new window

0
 

Author Closing Comment

by:Commsquare
ID: 31466114
Didn't work completely like this, but it put us on the correct track. Tx.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now