Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var validateAssetUpload = function () {
var selectFileElement = $("#selected-file");
var uploadErrorElement = $("#upload-error");
var assetFile = selectFileElement[0].files[0];
var zipFileType = "application/zip";
var bytesToMB = 1048576;
var fileSizeLimit = (window.location.pathname.indexOf("gadget") > -1) ? config.assets.gadget.fileSizeLimit : config.assets.layout.fileSizeLimit;
if (!assetFile) {
showInlineError(selectFileElement, uploadErrorElement, i18n_data_json["select.zip.file.to.upload"]);
return;
} else if (assetFile.type !== zipFileType) {
showInlineError(selectFileElement, uploadErrorElement, i18n_data_json["select.zip.file.to.upload"] + " " +
assetFile.type + " " + i18n_data_json["file.format.is.not.supported"]);
return;
} else if (assetFile.size / bytesToMB > fileSizeLimit) {
showInlineError(selectFileElement, uploadErrorElement, i18n_data_json["file.size.exceeded"]);
return;
}
return true;
};
var validateAssetUpload = function () {
var selectFileElement = $("#selected-file");
var uploadErrorElement = $("#upload-error");
var assetFile = selectFileElement[0].files[0];
var zipFileType = "application/zip";
var bytesToMB = 1048576;
var fileSizeLimit = (window.location.pathname.indexOf("gadget") > -1) ? config.assets.gadget.fileSizeLimit : config.assets.layout.fileSizeLimit;
if (!assetFile) {
showInlineError(selectFileElement, uploadErrorElement, i18n_data_json["select.zip.file.to.upload"]);
return;
} else if (assetFile.type !== zipFileType) {
showInlineError(selectFileElement, uploadErrorElement, i18n_data_json["select.zip.file.to.upload"] + " " +
assetFile.type + " " + i18n_data_json["file.format.is.not.supported"]);
return;
} else if (assetFile.size / bytesToMB > fileSizeLimit) {
showInlineError(selectFileElement, uploadErrorElement, i18n_data_json["file.size.exceeded"]);
return;
}
return true;
};