I have a form completely built, including the option for a file attachment (picture files only).
The problem is that when it emails the attachment, it is sent as a .att file, sometimes I I.E. just crashes on me.
SCRIPT LANGUAGE="JavaScript">
<!-- Hide From Old Browsers
extArray = new Array(".gif", ".jpg", ".png");
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 == ext) { allowSubmit = true; break; }
}
if (allowSubmit) form.submit();
else
alert("Please only upload files that end in types: "
+ (extArray.join(" ")) + "\nPlease select a new "
+ "file to upload and submit again.");
}
</script>
I also have a validate script that checks the field as well. The actual main part of my form is:
<form method='post' action="mailto:[email protected]" name='form1' onsubmit="return validate(this)" enctype='multipart/form-data'>
The form body is all text fields.
<input type=file name=uploadfile>
<input type=button name="Submit" value=http://www.webdeveloper.com/forum/archive/index.php/"Submit" onclick="LimitAttach(this.form, this.form.uploadfile.value)">
Without the picture attachment portion, it works fine. The form submits porperly, and it is all good. With the picture attachment part, my browser crashes.
The problem is that when it emails the attachment, it is sent as a .att file, sometimes I I.E. just crashes on me.
SCRIPT LANGUAGE="JavaScript">
<!-- Hide From Old Browsers
extArray = new Array(".gif", ".jpg", ".png");
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 == ext) { allowSubmit = true; break; }
}
if (allowSubmit) form.submit();
else
alert("Please only upload files that end in types: "
+ (extArray.join(" ")) + "\nPlease select a new "
+ "file to upload and submit again.");
}
</script>
I also have a validate script that checks the field as well. The actual main part of my form is:
<form method='post' action="mailto:[email protected]" name='form1' onsubmit="return validate(this)" enctype='multipart/form-data'>
The form body is all text fields.
<input type=file name=uploadfile>
<input type=button name="Submit" value=http://www.webdeveloper.com/forum/archive/index.php/"Submit" onclick="LimitAttach(this.form, this.form.uploadfile.value)">
Without the picture attachment portion, it works fine. The form submits porperly, and it is all good. With the picture attachment part, my browser crashes.