This is the final major hurdle before I release my web app.
How do I limit the size and type of attachments on a web app?
I realize that size may only be accomplished only after submission via a server agent. Or is there some Javascript method that could work here?
Regarding attachment types, I see no reason why this cannot be checked before submission.
I’ve done some reading and borrowing and implmented this JS function and call, but document.forms[0].uploadfile.value never seems to have a value.
Any suggestions?
function TestFileType( fileName, fileTypes ) {
dots = fileName.split(".")
//get the part AFTER the LAST period.
fileType = "." + dots[dots.length-1];
msg = (fileTypes.join(".").indexOf(fileType) != -1) ?
"" :
"Please only upload pictures of type: \n\n." + (fileTypes.join(" .")) + "\n\nPlease select a new file and try again."
return (msg)
}
file = document.forms[0].uploadfile.value
if (file) {
msg = TestFileType(file, ['gif', 'jpg', 'png', 'jpeg'])
if (msg != "") {
alert(msg)
return false
}
}