Cronthenoob Posted August 28, 2006 Share Posted August 28, 2006 I need a way to check for files in a folder, and then print out links to all of them.I know there is a way to do it, i've used it before but can't remember.Someone care to teach me? Link to comment Share on other sites More sharing options...
aspnetguy Posted August 28, 2006 Share Posted August 28, 2006 http://ca3.php.net/manual/en/function.scandir.php Link to comment Share on other sites More sharing options...
Jack McKalling Posted August 28, 2006 Share Posted August 28, 2006 My scripting friend also uses that function. But I disrecommended using scandir() for him. I prefer using the database to store the information when added to the site. When the content of some directory must be listed, all the data that is in the database can be used. I think this has some advantages over the scandir(), as with this exeptions can be made, or restrictions in whatever the user may view, for example. And they can be easily online edited But this isonly an alternative, no forcement.. Link to comment Share on other sites More sharing options...
aspnetguy Posted August 28, 2006 Share Posted August 28, 2006 you can easily filter the array that is returned...the contents can't be edited unless you have code that does it. If you keep a list of the folder contents in a databse what is the advantage? It just makes more work writing extra code and maintaining the list. Link to comment Share on other sites More sharing options...
Jack McKalling Posted August 28, 2006 Share Posted August 28, 2006 I think that using a database for the file management, is more editable. Yes you must write a piece of code to create and maintain it, but if you have that, you can have settings in an admin panel to turn new files on, off or edit their location or name.You wouldn't have to interfere with the files themself, via FTP. The piece of code would be able to do that by itself. With any interface you want, even what you want you're moderators to get (if you have them).But it is only my opinion, you may have your own of cource. And I don't say you must not use scandir() Link to comment Share on other sites More sharing options...
aspnetguy Posted August 28, 2006 Share Posted August 28, 2006 I hate to tell you, but regardless of wether you log it in a database or not in order to edit and rename files, etc you have ot edit the files themselves, so why add the extra step of the database in between?I understand what you are saying but for the most part it is more work thatn is needed. There are times when you'll want a database record of the files like in a CMS or something but for small applications it is needless. Link to comment Share on other sites More sharing options...
Jack McKalling Posted August 28, 2006 Share Posted August 28, 2006 Ok, the last thing is true, but the first not. You don't have to rename the files themself, or am I wrong and was php not able to rename them by script? if so, I meant the piece of code should have that too, rename files ability. Link to comment Share on other sites More sharing options...
justsomeguy Posted August 28, 2006 Share Posted August 28, 2006 I think you guys are talking about 2 different things. For simple file management, using filesystem functions and working with the files themselves is definately the way to go.For an online file manager or something like that, that lets people upload files and things like that, the database approach is definately the way to go. When I do something like that, I save the file with a different file name then was uploaded, store that name in the database, bury the file in a few subfolders, and use a separate download page to allow people to download it. Then people don't even know the location of the original file.But, for file/directory management, an extra database layer is mostly unnecessary. Link to comment Share on other sites More sharing options...
aspnetguy Posted August 28, 2006 Share Posted August 28, 2006 I was refereing to this statement You wouldn't have to interfere with the files themself, via FTPI was saying regardless of whether you store information about the file in a databse you still have to (with PHP code) edit the files thmeselves. Changing the data in the database is not enough.Sorry if that is not what you meant but that is the way it sounded. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now