I allow people to upload images onto my web server. I want to verify each image is less than 50Kb and is an image type, this is what I came up with
Verifying the files extension

<script language="javascript" type="text/javascript">
extArray = new Array(".gif", ".jpeg", ".jpg", ".png", ".bmp");
function LimitAttach(form, file) {
allowSubmit = false;
if (!file) return;
while (file.indexOf("\\") != -1)
file = file.slice(file.indexOf("\\") + 1);
ext = file.slice(file.indexOf(".")).toLowerCase();
for (var i = 0; i < extArray.length; i++) {
if (extArray[i] == ext) { allowSubmit = true; break; }
}
if (allowSubmit) return true;
else
alert("Please only upload files that end in types: "
+ (extArray.join(" ")) + "\nPlease select a new "
+ "file to upload and submit again.");
return false;
}
</script>
and I put this on my submit button
HTML Code:
onclick='return LimitAttach(this.form, this.form.Image.value)'
How do I change this if I have 6 fields in an array(Image[])