|Sep 13, 2006, 12: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 12:42 PM.
|Sep 13, 2006, 02: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, 02: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 03:00 PM.
|Sep 13, 2006, 03: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|
|Active Directory Issues After Lion Upgrade||andrewbecks||Mac OS X 10.7 Lion||13||Jan 15, 2012 07:29 PM|
|Need help when changing the name of the home directory folder in Lion||huntert93||Mac OS X 10.7 Lion||3||Sep 20, 2011 05:31 PM|
|Terminal, add text to the end of all text files in a directory.||Jesse Smith||Mac Basics and Help||2||Feb 22, 2011 02:13 PM|
|Listing directory contents?||lynkynpark86||iPhone/iPad Programming||6||Feb 19, 2011 07:12 PM|
|Is there a PHP page screenshot software witch can catch 2 more pages at the same time||youlichika||Web Design and Development||0||Nov 6, 2010 06:21 PM|
All times are GMT -5. The time now is 10:19 AM.