|Sep 13, 2006, 01:04 PM||#1|
PHP Directory Spider
I'm making a website for my band and I'm trying to make it so that my media page can list all of the files in a certain directory that have a certain extension, and link to them. Is there any way of doing that in PHP?
EDIT: The website in question is http://www.theautonomy.co.uk/
Last edited by satans_banjo; Sep 13, 2006 at 01:42 PM.
|Sep 13, 2006, 03:15 PM||#2|
Heres some slightly adapted code I was using for basically the same purpose.
Something to take note off, is that the function determines the file type by searching the filename using the strstr() function which is case sensitive, so take care when your specifying the file type. Because its searching the filename for the file type you should probably always include the period when specifying the file type. For example you have a file named mympg.php and you said to look for .mpg files, the function won't return that file as being of the specified type.
Also it filters out hidden files and directories by looking for filenames that begin with a period. It's pretty basic and its only been tested on a server running Linux and I don't really know much about hidden files under different operating systems so use at your own risk.
Hope this helps.
|Sep 13, 2006, 03:54 PM||#3|
Thanks - I'm not an experienced user of PHP, so would you be able to elaborate on how I could use that? Right now I've got a 'controller' file containing that function, and an instance of that function containing the variables. I then include() that file on the page, but for output I just get the entire contents of the controller file. I've never used functions before in PHP - any chance you could help?
Thanks again for the help
EDIT: Okay, I think I've got it, just one thing - how do I define the 'file type' variable? When I use ".mp3" it doesn't show any results
Last edited by satans_banjo; Sep 13, 2006 at 04:00 PM.
|Sep 13, 2006, 04:12 PM||#4|
Ok heres an example on how you would use the function.
<a href="example/directory/file.mpg">file.mpg</a> <a href="example/directory/file2.mpg">file2.mpg</a>
You've got the controller part right but it would be easier just to call the function against a variable in the main file and include the file containing the code as you said but it doesn't really matter. If you keep it as you have it the now then all you have to do is get rid of the first line in the above code and put it in the controller file.
Hope this helps you further.
|Thread Tools||Search this Thread|
|thread||Thread Starter||Forum||Replies||Last Post|
|[php] - php problems os x mountain lion 10.8.2||cakas6933||OS X 10.8 Mountain Lion||4||Jun 10, 2014 09:08 AM|
|copy a directory using bash - how to do it? error: is a directory (not copied).||cupboy1||OS X 10.8 Mountain Lion||0||Mar 23, 2014 10:50 PM|
|Stupid Spider Questions||Renzatic||Community Discussion||56||Sep 23, 2013 07:44 PM|
|Listing directory for php||gustavopi||Mac Programming||2||Sep 23, 2013 03:31 PM|
|iPhone 5 to be Spider Designed?||MacUserMichael||iPhone||10||Jul 10, 2012 11:57 PM|
All times are GMT -5. The time now is 06:50 AM.