Click to See Complete Forum and Search --> : Emailing file attachments


dawgbone
03-24-2003, 02:19 PM
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[i] == 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@domain.com" 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="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.

khalidali63
03-24-2003, 02:39 PM
Unfortunately ,you can not do this using only JavaScript.
You will have to use some server side programming language to separate the file from the email.

Cheers

Khalid