Jump to content

Recommended Posts

Just a question?

 

I am creating a client panel for users to store files on my server. ie: pdf's, images and docs. Is there a way to limit the size of there folder. for example. User has 500meg of space to use, and once he get upto the 500 he cannot upload any more?

 

I tried doing some google searches with little luck. If somebody could point me in the right direction it would be greatly appreciated.

Link to comment
https://forums.phpfreaks.com/topic/272868-directory-size/
Share on other sites

@cpd, it's a server side storage issue, no database one.

 

When the users upload a file, store it and its size into the database. Then when they next try, add up all of the sizes to determine if they can upload another.

 

Obviously this only works via a web-form. If he is using FTP or some other means, he will have to do something different. .quota files is a possibility.

Edited by scootstah
Link to comment
https://forums.phpfreaks.com/topic/272868-directory-size/#findComment-1404305
Share on other sites

When the users upload a file, store it and its size into the database. Then when they next try, add up all of the sizes to determine if they can upload another.

 

Well, to be clear I don't think that it's a web server issue, I think that OP wants to re-size a storage space on the server for every client, which has a home directory on the server.

Link to comment
https://forums.phpfreaks.com/topic/272868-directory-size/#findComment-1404310
Share on other sites

Sorry guys, just got in. It is a web issue and they will only have access to upload via webform. I like the idea of adding up all of there files and keeping that in a database. Never thought of doing it that way and then figuring out when the get to a set size to not allow any more, The directory structure will be ie: clients/username where username will be there directory to store there files with a cap of say 500 meg per username.

Link to comment
https://forums.phpfreaks.com/topic/272868-directory-size/#findComment-1404329
Share on other sites

As far as I can tell there isn't a specific issue jazzman1. The OP just asks for methods to limit the size of the directory contents.

 

I never mentioned limiting the file system with PHP, merely a method of tracking the total file space currently taken up by said user. There may be additional methods to ensure it directories don't exceed a specific amount and you could implement it as a precaution should it exist.

Edited by cpd
Link to comment
https://forums.phpfreaks.com/topic/272868-directory-size/#findComment-1404339
Share on other sites

It can be done both through server storage, or through database management. I use a managed file system (such as CPD is describing) on my web systems. When users upload files, references to them are stored in the database containing the actual file name (which may be different than the originally uploaded file name since I rename files if a file with the same name already exists on the server), the file path, and the file size. I also have another table that stores usage of the file, so that each time it is used, a new reference is created, so that I know when to whether or not to delete the actual file when a reference to it is deleted.

 

This managed file system is overkill for some sites however, and a simple check of actual file sizes in an existing directory will suffice.

 

Both systems have their place, so there is no 'right' or 'wrong' answer, there are just different ways of doing it.

 

In this case, since file sizes are to be calculated per user, I would go with the managed file system, so that the DB can be queried at any given time for a quick response as to the amount of storage that a given user is using.

Link to comment
https://forums.phpfreaks.com/topic/272868-directory-size/#findComment-1404360
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.