SkyRanger Posted January 8, 2013 Share Posted January 8, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/272868-directory-size/ Share on other sites More sharing options...
cpd Posted January 8, 2013 Share Posted January 8, 2013 Record in a database what they've uploaded and have a check in whatever carries out the upload? Quote Link to comment https://forums.phpfreaks.com/topic/272868-directory-size/#findComment-1404299 Share on other sites More sharing options...
jazzman1 Posted January 8, 2013 Share Posted January 8, 2013 Record in a database what they've uploaded and have a check in whatever carries out the upload? @cpd, it's a server side storage issue, no database one. @OP, what OS is running on the server? Quote Link to comment https://forums.phpfreaks.com/topic/272868-directory-size/#findComment-1404304 Share on other sites More sharing options...
scootstah Posted January 8, 2013 Share Posted January 8, 2013 (edited) @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 January 8, 2013 by scootstah Quote Link to comment https://forums.phpfreaks.com/topic/272868-directory-size/#findComment-1404305 Share on other sites More sharing options...
jazzman1 Posted January 8, 2013 Share Posted January 8, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/272868-directory-size/#findComment-1404310 Share on other sites More sharing options...
scootstah Posted January 8, 2013 Share Posted January 8, 2013 Considering he posted in "PHP Help", it sounds like a web issue. Quote Link to comment https://forums.phpfreaks.com/topic/272868-directory-size/#findComment-1404314 Share on other sites More sharing options...
SkyRanger Posted January 8, 2013 Author Share Posted January 8, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/272868-directory-size/#findComment-1404329 Share on other sites More sharing options...
jazzman1 Posted January 8, 2013 Share Posted January 8, 2013 Sorry guys, just got in. It is a web issue and....... No, it's not only the web issue! How do you resize the file system in a low level with php, еspecially linux one? Quote Link to comment https://forums.phpfreaks.com/topic/272868-directory-size/#findComment-1404337 Share on other sites More sharing options...
cpd Posted January 8, 2013 Share Posted January 8, 2013 (edited) 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 January 8, 2013 by cpd Quote Link to comment https://forums.phpfreaks.com/topic/272868-directory-size/#findComment-1404339 Share on other sites More sharing options...
haku Posted January 9, 2013 Share Posted January 9, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/272868-directory-size/#findComment-1404360 Share on other sites More sharing options...
SkyRanger Posted January 9, 2013 Author Share Posted January 9, 2013 Thank you haku. That is the direction I have been looking for, and that sounds like the easiest root to go. Quote Link to comment https://forums.phpfreaks.com/topic/272868-directory-size/#findComment-1404437 Share on other sites More sharing options...
jazzman1 Posted January 9, 2013 Share Posted January 9, 2013 For homework - http://souptonuts.sourceforge.net/quota_tutorial.html Quote Link to comment https://forums.phpfreaks.com/topic/272868-directory-size/#findComment-1404496 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.