Unable to limit accepted files

Hi All,
I’m a french user of kobotoolbox (sorry for my english :sweat_smile: ). I’m trying to limit a file question to PDF and Word formats (.pdf, .doc and .docx). I used body::accept column in an xls form to specify it.

When I open the Enketo form, it remains possible to upload another type of file such as image, excel file. I also try to activate it directly on the builder but I have the same issue.

Can you help me solve it ?

Welcome to the community, @adebayoltj! It seems like you tried this with Enketo. Could you also try it out with the Collect android app to see how it behaves?

Hi @Kal_Lam
I’ve tried it with KoboCollect and the result is similar. I’ve also made another test (unsuccessfull) with the xls form released in this kobotoolbox support article “Photo”, “Audio”, “Video” and “File” question types.

1 Like

Hi @adebayoltj, using the body::accept to specify accepted file formats only filters for these formats in the device’s file picker — unfortunately it does not restrict one from uploading a file that is outside of the desired formats. So in other words, it is a guide for the person completing the survey rather than a security feature.

1 Like

Hi @Josh, thanks for the explanation. Does Kobotoolbox have another function more appropriate for my purpose ?

Hi, @adebayoltj and to anyone looking for a similar solution, I used the constraint column of my file question with a regex to only accept PDF and Word documents. The regex is: regex(., '.*\.(docx|doc|pdf)$'). In addition to using body::accept with the following value: application/pdf,.doc,.docx

This still allows the user to browse and select other file types, but the constraint will prevent the user from submitting until they choose PDF or Word, and the body::accept will browse by default for these types only.

1 Like