Jump to content

Apache server file list on php


zahid

Recommended Posts

I rate myself a beginner in php.My question is that my files are shown on a apache web server, a file list appeares. please see the linkhttp://student.bu.ac.bd/~u06304006/TSRbu/Summer/How can I integrate this file list on php file so that ppl can download through that file.I mean if user opens the php file they will see the file list on php not the apache server list so that i can integrate that file on my phpbb forum.& what will be the procedure if the user is not logged in then the download will not start but they will asked to be logged in. OR "http://student.bu.ac.bd/~u06304006/TSRbu/Summer/" this folder will not allowed to be public view or direct access rather user must have to access via my site.

Link to comment
Share on other sites

You need to put a default document (such as index.html) into the folder so that it won't show the file list. If you want to list files in PHP, you can use the scandir function:http://www.php.net/manual/en/function.scandir.phpIt's up to you to check if each one is a file or directory, show the icons, or whatever you want to do. For password-protecting, if you're just showing a folder list then people can just type the filenames in themselves to download whatever they see there. You can set it up so that if they click on a link they have to log in first, but they can always just type in the filename if you're showing that to them. If you want it to actually be secure then one way would be to store the file and directory structure inside a database, or inside a folder on the server that you deny the public access to, and then use PHP as a proxy to read the file and send it to the user if they're logged in. You can use .htaccess to restrict the permissions on a directory, but if you want to integrate with forum software and other things that might not be the best idea. It might be better to have a download directory where you store everything and you deny the public access to that directory. PHP would still be able to read files in there and send the data to the user.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...