Quantcast
Channel: AjaxControlToolkit Work Item Rss Feed
Viewing all articles
Browse latest Browse all 4356

Created Issue: AjaxFileUpload - Bug Uploading .docx files [27357]

$
0
0
I've had trouble uploading .docx files using AjaxFileUploader...they seemed to be ignored even though "docx" was in AllowedFileTypes.

The problem arises in the following function in AjaxFileUpload.js, where it turns out that file.type of a word document (.docx file) is "application/vnd.openxmlformats-officedocument.wordprocessingml.document" and it's actually using this as a comparison against the list of file types.

```
_html5AddFileInQueue: function (files) {
debugger;
for (var i = 0; i < files.length; i++) {
var file = files[i];
var fileType;
if (file.type != '') {
fileType = file.type.substring(file.type.lastIndexOf('/') + 1);
}
else {
fileType = file.name.substring(file.name.lastIndexOf('.') + 1);
}
if (this._validateFileType(fileType)) {
var uploadableFile = new Object();
uploadableFile.file = file;
uploadableFile.id = Sys.Extended.UI.AjaxFileUpload.utils.generateGuid();
this._addToQueue(uploadableFile);
}
else {
}
}
}
```

I'm not sure when using file.type (rather then the end of file.name) would be appropriate, but simply removing the file.type comparison seems to fix the problem for me and lets me upload .docx files as expected.

```
_html5AddFileInQueue: function (files) {
debugger;
for (var i = 0; i < files.length; i++) {
var file = files[i];
var fileType;

fileType = file.name.substring(file.name.lastIndexOf('.') + 1);

if (this._validateFileType(fileType)) {
var uploadableFile = new Object();
uploadableFile.file = file;
uploadableFile.id = Sys.Extended.UI.AjaxFileUpload.utils.generateGuid();
this._addToQueue(uploadableFile);
}
else {
}
}
},
```

Viewing all articles
Browse latest Browse all 4356

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>