How to check file upload type in Angular JS?

I am using the Angular File Uploader library in Angular JS. Here is filtersone that allows you to set file types for download. I do it like:

uploader.filters.push({
    name: 'imageFilter',
    fn: function (item /*{File|FileLikeObject}*/, options) {
    var type = '|' + item.type.slice(item.type.lastIndexOf('/') + 1) + '|';
         return '|doc|txt|docx|xml|pdf|djvu'.indexOf(type) !== -1;
   }
});

The problem is that the user can change the extension file, for example, change *.exeto *.pdf, and after Angular, the loader will add the file to the download queue.

And how can I show the information in the template where the PDF and txt files are?

+4
source share
1 answer

You indicated one of the main problems with uploading files to the server (congratulations!) :)

, AngularJS ( , AngularJS API-, JavaScript, AngularJS JavaScript ).

" MIME javascript ?" , MIME .

, :

  • (, , )
  • API, .

.

( ) - PHP - , " PHP?" :

mime_content_type Fileinfo, PHP , . , .

-, system ( "file -bi $uploadedfile" ), , .

( ) API-, ( ).

+1

All Articles