PDA

View Full Version : cWebFileUpload mime types



chuckatkinson
16-Apr-2014, 10:37 AM
Is it possible to restrict the mime type for file uploads?

Harm Wibier
17-Apr-2014, 02:49 AM
Yes, you can use psAccept property. I just delivered the following description for the reference to Dennis:

cWebBaseFileUpload – psAccept
This web property filters the files that can be selected. It can be set to to a comma separated list of mime types and file extensions. Note that only modern browsers support filtering on mime types and older browsers will ignore these. In modern browsers the file selection dialog will apply the filter already so that only matching files will be displayed and selectable.
Sample values are:


Set psAccept to ".jpg,.png,.gif" // image files based on extension
Set psAccept to "image/*,.jpg,.png,.bmp,.gif" // image files based on mime type with filtering on extension for older browsers
Set psAccept to "image/*,video/*" // image files and videos accepting anything on older browsers

chuckatkinson
17-Apr-2014, 05:42 AM
Thanks Harm - that's what I was looking for.

chuckatkinson
17-Apr-2014, 09:05 AM
Seems the psAccept mime type is not carrying forward to the file browser file types. I still get a prompt with "All Files" in the dialog.

Harm Wibier
17-Apr-2014, 09:21 AM
What string do you use for psAccept and which browser are you using to test?

Unfortunately browser support on this is pretty weak and not all browsers actually show the filter.

chuckatkinson
17-Apr-2014, 10:06 AM
Firefox v28. The mime type is ".pdf"


EDIT: tried changing it to "application/pdf"

No change

chuckatkinson
17-Apr-2014, 10:17 AM
Harm you are correct about browser spotty coverage. Just tested in IE and with application/pdf it works.