Setting the max file upload count outside of the html field

Archived from the Transloadit support forum. Originally posted on February 25, 2014; details may be outdated, see our docs for current behavior. Original thread

Hi

I’ve found the html5 min/max file count via the file input field to not work so great.

Is it possible to ignore all but the fix X files (a max count setting)?

Also - the max upload, is that all the files combined and is it measured in K?

Thanks,
Matt

Hey Matt,

I’ve found the html5 min/max file count via the file input field to not work so great.

Not sure I understand. Do you mean the file input field attributes for this?

Is it possible to ignore all but the fix X files (a max count setting)?

Did you mean “first” instead of “fix”?

I think it’s possible by inspecting the value attribute of your file input field and see how many files were selected. If that is bigger than a certain X, you could display a warning message and block form submission. If this does not work, then you could most likely you the html5 file reader API.

Also - the max upload, is that all the files combined and is it measured in K?

You probably mean the “max_size” parameter. Yes, that is the size of all uploads combined.

I hope this helps.

Kind regards,
Tim

Co-Founder Transloadit
@tim_kos

RE: Not sure I understand. Do you mean the file input field attributes for this?
Yeah, I meant (not that it worked)

I’ve found some jquery methods (http://stackoverflow.com/questions/10105411/how-to-limit-maximum-items-on-a-multiple-input-input-type-file-multiple).

But, it would be annoying for people to have to re-select.

What I wanted to do was above the uploader say:
“If you select multiple files - only the first 5 files under 4MB will be uploaded.”

then the system can let them select all if they do by mistake, and when the files upload it will only take the first 5 under 4MB and ignore the rest …

Is this possible?

Thanks,
Matt

Hey Matt,

okay got it. Yeah a simple notification at the top should suffice I think. If people ignore it, then they should not be annoyed when they have to reselect.

Is this possible?

Yeah it’s possible, but only with the File Reader API. And you will need my XHR implementation for that. https://github.com/tim-kos/transloadit_xhr

Kind regards,
Tim

Co-Founder Transloadit
@tim_kos

Hi Tim

Thanks for the info. I suppose I just wanted it as an attribute in the standard implementation …

Matt

I see. I am adding this to our TODO list for a future release.

I am going to close the ticket for now. Please let me know in case you have more questions.

Kind regards,
Tim

Co-Founder Transloadit
@tim_kos