Question

I am using fineuploader php server code to handle image uploads.

I have searched web and so far couldn't find what I want.

I want to allow user upload maximum 4 images at a time. (no multiple select allowed, user need to select one by one image)

I can solve it with client side, but what about server side? How do I detect if more than 4?

Example: FB allows select multiple images up to few hundreds. imagine FB only allow maximum 4 images

Any solution to this?

UPDATE I need 4 max for one function. others function need more than 4. I don't think it is good idea to set php.ini

Was it helpful?

Solution

Both of the other answers here assume that multiple files are sent with a single request. That is not true with Fine Uploader. Each file is sent in a separate request.

As you mentioned, Fine Uploader already handles this client-side with the validation.itemLimit option. If you want to add a server-side check as well, you'll need to ensure some user data, such as an ID, is passed with each request. This way, you can limit a specific user to a set number of files. You should already have some sort of a cookie set that allows your server to match a request to a specific user. This cookie will be passed, by default, with each request.

OTHER TIPS

PHP Count - www.php.net/count‎

E.g.

if(count($_FILES) > 4) { /*Throw error*/ }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top