Jump to content

List Out The Files in a Directory for Download


ankur218

Recommended Posts

Hello everyone,I am making a resource directory for my college. I don't know PHP and I am learning things along the way. I have created the upload part successfully using dynamic dropdown lists. I have added 3 levels, first to choose which stream/dept, then which semester and then which semester, and on clicking upload, the files goes to the desired directory correctly.Now, I want to know how to display all the files that are being uploaded? They are all in the directory. How do I list them and show my users/visitors so that they can choose what to download? The example I have attached only has 2 engg streams, 2 sems under both, and 2 subjects under each sem. I want to list out all in a segregated way. Say a page that has CSE/SEM1/ Data Structures/all the files under this category, another page has CSE/SEM2/Networks/all the files under this category. And not only list out but also form a link so that they can download it.Please check my attachment/link and please help me overcome this problem at the earliest.http://www.mediafire.com/?hevt1f4a1rpbyvpThank You :)

Link to comment
Share on other sites

One way is to use the SPL DirectoryIterator class, there are examples here: http://www.php.net/manual/en/class.directoryiterator.php There's also a recursive version of it: http://www.php.net/manual/en/class.recursivedirectoryiterator.php There's also a class for working with a particular file; http://www.php.net/manual/en/class.splfileobject.php You can also review the list of directory functions: http://www.php.net/manual/en/ref.dir.php and filesystem functions: http://www.php.net/manual/en/ref.filesystem.php

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...