开发者

Storing file information in a database

I am buildi开发者_C百科ng a file hosting site and would like to keep track of users file quota ( Each user is only allowed 2gb of file storage). Could anyone explain how I could store file name, type and importantly size of all files uploaded by a user in a mysql database. And is it possible to calculate using php script or MySQL when users exceed limit, display a message and reject any further uploads until files have been deleted by them to reduce quota?

I am fairly new to mySQl and would really appreciate some simple guides on how to achieve this.

Thanks

R


...is it possible to calculate using php script or MySQL when users exceed limit, display a message and reject any further uploads until files have been deleted by them to reduce quota?

Short Answer

Yes.

Long Answer

Yes but it will take some coding.

I recommend:

  • Use PHP for the file-handling side of things
  • Store information about the files in your MySQL database

You definitely can store the file name, file type and size of each file in your database.

You can use this data to ensure that a user has quota remaining, and warn / block them when they try to upload files once they've reached their quota.

If you're new to MySQL / PHP, then this sounds like a great project to get you started with both.

I recommend the Tizag tutorials: PHP / MySQL.

Once you've covered the basics, please read about database normalization.

Edit: to find the size of a file with PHP, use filesize.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜