如何只检测doc,docx,xl​​s,xlsx,txt,ppt,pps和pdf文件

时间:2017-12-15 02:04:07

标签: javascript

我有以下代码在firebase存储中上传文件:

if ($('#arquivo')[0].files.length > 0){

                file = $('#arquivo')[0].files[0];

                var metadata = {
                    contentType: 'image/jpeg',
                };

                var uploadTask = imagesRef.child('documentos/' + file.name).put(file, metadata);

                uploadTask.on('state_changed', function(snapshot){
                    console.log('state changed')
                    //console.log(snapshot)
                }, function(error) {
                    console.log('error')
                    console.log(error)
                    closeLoader();
                }, function() {
                    console.log('arquivo uploaded')
                    downloadURL = uploadTask.snapshot.downloadURL;

                    documento.arquivo = downloadURL

                    documentosRef.child(keyDocumento).update(documento);
                    window.location = "/documentos?estado=updated_success"; 
                });
}

我希望这些文件只有扩展名doc,docx,xl​​s,xlsx,txt,ppt,pps和pdf文件

我怎么能这样做?

0 个答案:

没有答案