I am trying to upload doc or docx files in my application :
The view :
<div class="col-xs-12">
<input type="file" ng-file-select="onFileSelect($files)"/>
<table>
<td ng-repeat="file in files">{{ file.name }} </td>
</table>
</div>
The ctrl :
controller: ['$scope', '$modalInstance', 'rule', '$upload', '$resource', function (modalScope, modalInstance, originalRule, $upload, $resource) {
modalScope.isLoaded = true;
modalScope.files = [];
modalScope.onFileSelect = function ($files) {
var maxSizeString = '10 Mo';
var maxSizeValue = 10 * 1024 * 1024; // 10Mo
var supportedFileFormat = ['image/gif', //
'image/jpeg', //
'image/png', //
'image/tiff',//
'image/svg+xml', //
'application/pdf',//
'application/doc',//
'application/docx',//
];
$.each($files, function (index, file) {
if (_.contains(supportedFileFormat, file.type)) {
if (file.size > maxSizeValue) { //10Mo
modalScope.fileUploaded = false;
} else {
modalScope.fileUploaded = true;
modalScope.files.push(file);
}
} else {
modalScope.fileUploaded = false;
}
});
};
I can upload images or .pdf but not .doc or .docx.. What am I doing wrong? Note that I am using the version 1.3.1 of ng-file-upload. Can't upgrade to the 6.x but I don't think that the issue come from here.
The right MIME types are the following:
.doc -> application/msword
.docx -> application/vnd.openxmlformats-officedocument.wordprocessingml.document
Other MS format MIME types are summarized here.