Nick99 Posted May 31, 2008 Share Posted May 31, 2008 Hey, I would know how to find files incrementally in PHP. I'm having a hard time finding examples. By incrementally i mean like, find one file, then go on to another. Any help is appreciated. Link to comment Share on other sites More sharing options...
Jesdisciple Posted May 31, 2008 Share Posted May 31, 2008 Can you describe your situation more? What's different from just finding 2 files? EDIT: And what do you mean by "finding" files - opening them? Link to comment Share on other sites More sharing options...
Nick99 Posted May 31, 2008 Author Share Posted May 31, 2008 I mean like, find a file, display it, find another file, display it, find another, and so forth Link to comment Share on other sites More sharing options...
Jesdisciple Posted May 31, 2008 Share Posted May 31, 2008 So you have a list of files and the user should see each in turn. Write a page that shows one file, whose name (or index in an array of filenames) was passed via GET. To that page, add either a Next (and Previous) button or a menu with all files listed. Make the button(s)/menu change the GET parameter when clicked. Link to comment Share on other sites More sharing options...
Nick99 Posted June 1, 2008 Author Share Posted June 1, 2008 No, I mean find any file in the directory, and display it Link to comment Share on other sites More sharing options...
Wander Posted June 1, 2008 Share Posted June 1, 2008 you can use glob() to get all files in a directory, and fopen and fread to get the contents of the file Link to comment Share on other sites More sharing options...
Jesdisciple Posted June 1, 2008 Share Posted June 1, 2008 Be careful with that, though; you don't want the user to see just any file on your server. You should implement some kind of filter for the user input so, for example, they can't use "../filename" to go up the directory tree. If you do that and only put files that aren't "classified" into that directory, I think that should be enough. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.