如何用PHP创建一个多用户文件服务器系统?

I'm just looking a big picture idea here; I can google specifics once provided with guidelines.

I want to make a relatively simple file hosting website such as dropbox or skydrive for mainly pedagogical reasons.

Making a multi-user login and registration system with PHP and MySQL is pretty straight forward, but how would I go about managing file directories and permissions for each user?

At its simplest: Store files somewhere in any hierarchy you want in a location that's not simply publicly accessible through the web server. Store meta information about each file in a database. In said database, store who the owner of the file is. Write a script that allows people to download those files (see readfile), require that users are logged in and that only owners of files can them.

There are probably hundreds of ways to do this, but this is what I would do:

  • They should never have a direct download path as it can be abused.
  • All files could be stored in the same place.
  • File names should be changed to unique ids to avoid dupilcates.
  • Store the file name, unique id, and user id in a database.
  • When they visit the page for the unique id, you can do your checks and display the file info.
  • You will then pass the file to them rather than having them download it directly.
  • Their user page would show file names and links to those pages, etc.

I hope that is a good jumping off point.