Hi, I need to write a text file viewer (not the directory tree, but the actual file contents) for use in a browser. It will be used to view large files, I want to give the user the ability to actually ummm, browse the file, ie prev page & next page button, while each page will show only a portion of the file.
Two question:
* Is there anyway to pass the file descriptor through POST (or something) so that on each page I can keep reading from an already open file, and not starting all over again (again - huge files)
* Is there a way to read the file backwards? Will be very useful for browsing back in a file.
Any other implementation ideas are very welcome. Thanx
Text file viewer in browser
Moderator: General Moderators
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Text file viewer in browser
You don't need to pass the file descriptor, just pass the current position (page or line or byte) and the show then current page.
(#10850)
Re: Text file viewer in browser
Try fopen, fseek & readfile/fread ...
Re: Text file viewer in browser
Thanx dudes, I'm on it
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Text file viewer in browser
If you are having troubles getting it to work, the Skeleton Pagination component has a file adapter and an example showing paging through the a text file. It does all the first/last, prev/next, page links for you. If you drop it in a webserver directory then examples/pagination/example_adapter_file.php is a working example. The adapter is pretty basic, so for very large text files you might want to optimize by getting the byte offsets of all the pages and then seeking.
You can download it here:
http://skeleton.googlecode.com/files/sk ... .7.3.1.zip
You can download it here:
http://skeleton.googlecode.com/files/sk ... .7.3.1.zip
(#10850)