Form file upload type validation

Hi, I love Netlify forms, but i was wondering if it would be possible to only accept certain file types, by mime or extension using Netlify forms. This feature would ideally be an extra field that we can add to the Netlify form HTML. I do not want to write my validation in client side javascript, as this can be easily gotten around.

I think it would be quite important from a security standpoint, as right now, we just get a long link to the file, it could in fact be a malicious file, and a user may just download that without thinking.

Please let me know your thoughts :slight_smile:

1 Like

I think you could do this validation using serverless functions. However, that might not work with Netlify forms. Before you get confused, hear me out.

You can use submission-created function and that would be triggered as soon as the form has a verified submission. But yes, that’s the problem. By then, the submission is already created and logged into your dashboard. However, you could use a custom serverless function and a non-Netlify form to handle the validation on server-side instead of client-side. The problem would be to store the files and for that you’d need external storage like Firebase hosting or AWS S3.

It’s a good feature request to do this natively, but till the time it actually gets implemented (if they decide to implement it), you might have to use this tacky workaround.

2 Likes

Hey, thanks for the reply @hrishikesh

Great idea about using a serverless function! I’ll definitely try that out.

Do you know how/when I’ll find out if “they” accept this feature request? And who “they” actually is?

Thanks so much

They is our product team. They are constantly working on a lot of things and the implementation of a feature would depend on user demand among other things. So, I don’t have a confirmation as to if/when the feature would be added.