With uploadify I could set the allowed file types like
'fileType' : '*.jpg;*.gif;*.png;*.jpeg;',
and it would display in the dialog box All files(*.jpg;*.gif;*.png;*.jpeg;)
Is there anyway in uploadifive to get it to work exactly like this, I have used various options that I have found in the forum and the closest I have got is from this thread code below:
'fileType' : ["image\/gif","image\/jpeg","image\/png","image\/jpg", "application\/pdf"],',
var accept_types = '';
if(typeof settings.fileType !== 'object'){
settings.fileType = [settings.fileType];
}
for (var i=0;i<settings.fileType.length;i++){
var filetype_match = /^([a-z0-9]+)$/g.exec(settings.fileType[i]);
if(filetype_match != null){
accept_types += filetype_match[1]+'/*,';
}else{
accept_types += settings.fileType[i]+',';
}
}
accept_types = accept_types.slice(0,accept_types.length-1);
if(accept_types.length > 0){
input.attr('accept', accept_types);
}
// Check the filetype
if (settings.fileType) {
if ($.isArray(settings.fileType)) {
var isValidFileType = 0;
for (var n = 0; n < settings.fileType.length; n++) {
if (file.type.indexOf(settings.fileType[n]) > -1) {
alert(isValidFileType + 'valid file');
isValidFileType = 1;
}
}
if (!isValidFileType) {
alert(isValidFileType + 'not validid');
alert(settings.fileType);
$data.error('FORBIDDEN_FILE_TYPE', file);
}
} else {
if (file.type.indexOf(settings.fileType) < 0) {
$data.error('FORBIDDEN_FILE_TYPE', file);
}
}
}
This works great, however by default it still displays "All files(.)" as default with the option to select the allowed files from the drop down.
ideally I would like it to look something like "All supported files types (.pdf, .jpeg)" etc to appear as the default
I do not like the functionality that the forbidden file types uses as I want my users to see what files they can upload and not gamble on a click only for it to say forbidden file etc
Thanks
Lee