{ getFileUrl: function getFileUrl(fileInputId) { var uri = { url: '', filename: '', filetype: '', data: '' }; var fileObj = typeof fileInputId === 'string' ? document.getElementById(fileInputId) : fileInputId; if (!utils.isCanUploadFileAsync || !fileObj) { return uri; } try { if (window.URL.createObjectURL) { var fileItems = fileObj.files; if (fileItems.length > 0) { var u = fileItems.item(0); uri.data = u; uri.url = window.URL.createObjectURL(u); uri.filename = u.name || ''; } } else { // IE var u = document.getElementById(fileInputId).value; uri.url = u; var pos1 = u.lastIndexOf('/'); var pos2 = u.lastIndexOf('\'); var pos = Math.max(pos1, pos2); if (pos < 0) uri.filename = u;else uri.filename = u.substring(pos + 1); } var index = uri.filename.lastIndexOf('.'); if (index != -1) { uri.filetype = uri.filename.substring(index + 1).toLowerCase(); } return uri; } catch (e) { throw e; } }, getFileSize: function getFileSize(file) { var fileSize = this.getFileLength(file); if (fileSize > 10000000) { return false; } var kb = Math.round(fileSize / 1000); if (kb < 1000) { fileSize = kb + ' KB'; } else if (kb >= 1000) { var mb = kb / 1000; if (mb < 1000) { fileSize = mb.toFixed(1) + ' MB'; } else { var gb = mb / 1000; fileSize = gb.toFixed(1) + ' GB'; } } return fileSize; }, getFileLength: function getFileLength(file) { var fileLength = 0; if (file) { if (file.files) { if (file.files.length > 0) { fileLength = file.files[0].size; } } else if (file.select && 'ActiveXObject' in window) { file.select(); var fileobject = new ActiveXObject('Scripting.FileSystemObject'); var file = fileobject.GetFile(file.value); fileLength = file.Size; } } return fileLength; } }