Hello,
Seems simple, but how do I get the MaxFileSize client side? I've created a standard JS function for validation:
(Hope it helps others)
I thought it useful to inform the user that not only the file is to large, but also what the maximum file size is. Since this is a function that is used for many purposes, I want the function to retrieve something like: sender."get_maxFileSize"? So, get the MaxFileSize via the sender.
Thanks in advance,
Erik
Seems simple, but how do I get the MaxFileSize client side? I've created a standard JS function for validation:
function
OnClientValidationFailed(sender, args) {
try
{
var
fileExtention = args.get_fileName().substring(args.get_fileName().lastIndexOf(
'.'
) + 1, args.get_fileName().length);
if
(args.get_fileName().lastIndexOf(
'.'
) != -1) {
//this checks if the extension is correct
if
(sender.get_allowedFileExtensions().indexOf(fileExtention) == -1) {
//alert("Wrong Extension!");
var
msg =
'The file upload has failed because this is not an allowed extension. Allowed extensions are {0}.'
;
msg = msg.replace(
"{0}"
, sender.get_allowedFileExtensions());
radalert(msg, 400, 200,
'The file upload has failed.'
,
null
,
null
);
}
else
{
//alert("Wrong file size!");
var
msg =
'The file upload has failed because the file is to large. Maximum file size allowed is {0} Kb.'
msg = msg.replace(
"{0}"
, 4096000 / 1024);
radalert(msg, 400, 200,
'The file upload has failed.'
,
null
,
null
);
}
}
else
{
//alert("not correct extension!");
var
msg =
'The file upload has failed because this is not an allowed extension. Allowed extensions are {0}.'
;
msg = msg.replace(
"{0}"
, sender.get_allowedFileExtensions());
radalert(msg, 400, 200,
'The file upload has failed.'
,
null
,
null
);
}
}
catch
(ex) {
alert(
"JS Error #1311161741:"
+ ex);
}
setTimeout(
function
() { sender.deleteFileInputAt(0); }, 10);
}
(Hope it helps others)
I thought it useful to inform the user that not only the file is to large, but also what the maximum file size is. Since this is a function that is used for many purposes, I want the function to retrieve something like: sender."get_maxFileSize"? So, get the MaxFileSize via the sender.
Thanks in advance,
Erik