I have the upload widget setup in async mode and have specified a Select event function for validation of the selected file type.
Everything works in FF and IE, but in chrome v15.0.874.121 the event data object passed into the select event method is different from the documentation when a file is dragged and dropped.
Here is the object that is passes when the Select button is clicked and a file is selected in chrome, FF, and IE or drag and dropped in FF.
e.files
[
Object
extension: ".gif"
name: "DiscMen.gif"
rawFile: File
size: 18578
__proto__: Object
Here is the object that is passed when a file is dragged and dropped on the drop zone in Chrome.
e.files
FileList
0: File
fileName: "DiscMen.gif"
fileSize: 18578
lastModifiedDate: Date
name: "DiscMen.gif"
size: 18578
type: "image/gif"
webkitRelativePath: ""
__proto__: File
length: 1
__proto__: FileList
my html:
<input name="files" id="files" type="file" />
my Script:
$("#files").kendoUpload({
showFileList: false,
multiple: false,
select: onFileSelected,
async: {
saveUrl: Site.RootUrl + "Account/UploadAvatar",
saveField: "avatarFile",
autoUpload: true
},
localization: {
"select": Site.GlobalResources.Account_Settings_Upload_Avatar_Select_Button,
"dropFilesHere": Site.GlobalResources.Account_Settings_Upload_Avatar_Drop_Zone_Message
}
});
function onFileSelected(e) {
if (e.files[0].extension != '.jpg') {
e.preventDefault();
}
}
Everything works in FF and IE, but in chrome v15.0.874.121 the event data object passed into the select event method is different from the documentation when a file is dragged and dropped.
Here is the object that is passes when the Select button is clicked and a file is selected in chrome, FF, and IE or drag and dropped in FF.
e.files
[
Object
extension: ".gif"
name: "DiscMen.gif"
rawFile: File
size: 18578
__proto__: Object
Here is the object that is passed when a file is dragged and dropped on the drop zone in Chrome.
e.files
FileList
0: File
fileName: "DiscMen.gif"
fileSize: 18578
lastModifiedDate: Date
name: "DiscMen.gif"
size: 18578
type: "image/gif"
webkitRelativePath: ""
__proto__: File
length: 1
__proto__: FileList
my html:
<input name="files" id="files" type="file" />
my Script:
$("#files").kendoUpload({
showFileList: false,
multiple: false,
select: onFileSelected,
async: {
saveUrl: Site.RootUrl + "Account/UploadAvatar",
saveField: "avatarFile",
autoUpload: true
},
localization: {
"select": Site.GlobalResources.Account_Settings_Upload_Avatar_Select_Button,
"dropFilesHere": Site.GlobalResources.Account_Settings_Upload_Avatar_Drop_Zone_Message
}
});
function onFileSelected(e) {
if (e.files[0].extension != '.jpg') {
e.preventDefault();
}
}