I have a list of file types I don't want to accept, but Filestack only has fields for accepted extensions and mimetypes. How can I prevent the upload of these files?

In v2 there is no parameter that lets you set a list of file types you don't want uploaded. There are only parameters that let you specify what mimetype or extensions you do want.

In order to prevent someone from uploading specific file types, you would need to list all the file types you will accept. If your are using the mimetypes parameter this becomes easier because you can use wildcards like "image/*", to say you will accept all image filetypes. With the extensions parameter, you would need to list them all out like [".jpg",".gif",".png", etc..].

One note of caution when providing a long list of extensions or mimetypes is that these get appended to the Filestack dialog URL.


This is important because some browsers have a limit on how many characters are allowed to be in a URL. Internet Explorer, for example, has a limit of 2,083 characters for URLs. So if you put a really long list of extensions or mimetypes, you could go over this limit and then the dialog will fail to load because the URL will be invalid.

In v3 however, it is possible to provide both extensions and mimetypes that you want to accept, and it is also possible to reject certain filetypes by defining your own custom functions.

Accept all images and MOV files, except for PNG files

Accept image and MOV files except for PNG Files
client.pick({ accept: ['image/*','.mov'], onFileSelected: function(file) { console.log(file.mimetype); if (file.mimetype = 'image/png') { throw new Error('Please select a file that is not a PNG'); } } }).then(function(result) { console.log(JSON.stringify(result.filesUploaded)) })