Jump to content

Limit upload capacity for user (PHP/MySQL)


Mido

Recommended Posts

Hello!

 

I want to make the users in the website able only to upload, for example, 1 GB, so that when a user finishes the 1 GB available for his files, he cannot upload more files.

 

I know how to set up upload limit for a single file in the upload page, or even globally for anyone to upload. But I would like to know how to make each user has specific capacity, and how it is updated so that if he uploads 0.5 GB he has only 0.5 GB left.

 

I thought of creating a column in the `users` or something concerning upload limit that I will set it (one GB for example). If I will do that, how will I be able to determine how much he uploaded?

 

Any help would be appreciated.

 

Thank you!

 

 

Link to comment
https://forums.phpfreaks.com/topic/248137-limit-upload-capacity-for-user-phpmysql/
Share on other sites

I thought of creating a column in the `users` or something concerning upload limit that I will set it (one GB for example). If I will do that, how will I be able to determine how much he uploaded?

When they upload something, record how big it was. 

You would keep the total of their uploads.  So, when they uploaded something new, you add it to the previous amount, and when the delete something you ...

 

There is no need to know the number of files they have, unless you are going to limit that also. To calculate the files a user already has, just pass them to the filesize() function, and keep a running total.

So you have a whole bunch of files on your filesystem but you don't know who uploaded what?  unless you specifically logged this information you cannot get it back. You can start from right now and start recording, but there's no way to add up a random number of files based on which web user created them.

 

-Dan

Archived

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

×
×
  • 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.