[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details

ASPUpload - Form to Upload attachments and then email

Asked by AvanteIT in Active Server Pages (ASP), Access Forms, WebObjects

Tags: ASP, IIS, Webserver

I have found the script below and was wondering what is needed to make it run correctly on my IIS server.

I have tried in IIS 7.0 and 6.0. Using one of the ASPUpload templates and that uploaded a file correctly so ASPUpload is installed correctly.

I created the DIR uploaded/ in the same directory as "contact-me.asp"

Everytime I hit GO it directs to http://localhost/asp/contact-me.asp?up=1 and gives a http 500 internal error... Any ideas?
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
<%
'check if form has been posted or if this is just the first page view
if request.QueryString("up") = "1" then
dim Upload, maxbytes
maxbytes = 102400
Set Upload = Server.CreateObject("Persits.Upload.1")
Upload.Save server.MapPath("uploaded\")
%>
Files:<BR>
<%
Private sub deleteFile(filespec)
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
if fso.FileExists(filespec) then
fso.DeleteFile filespec, true
end if
Set fso = Nothing
End sub
 
Function returnFileName(pth)
dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
returnFileName = fso.getFileName(pth)
set fso = Nothing
End Function
 
Private Sub moveFile(src, dest)
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
if fso.FileExists(dest) then
fso.DeleteFile dest, true
end if
fso.MoveFile src, dest
Set fso = Nothing
End Sub
Dim MyCDONTSMail
Set MyCDONTSMail = CreateObject("CDONTS.NewMail")
MyCDONTSMail.From= Upload.Form("email")
MyCDONTSMail.To= "I changed this to my email address"
MyCDONTSMail.Subject="This is a Test"
MyCDONTSMail.Body= Upload.Form("message")
 
For Each File in Upload.Files
filename = returnFileName(File.Path)
SELECT CASE LCase(right(File.Path, 4))
CASE ".jpg"
if File.Size < maxbytes then
sendMail = true
MyCDONTSMail.AttachFile File.Path
Response.Write filename & " (" & File.Size &" bytes) was sent.<BR>"
else
Response.Write filename & " exceeded the maximum file size of " & maxbytes & " bytes."
end if
CASE ".gif"
if File.Size < maxbytes then
sendMail = true
MyCDONTSMail.AttachFile File.Path
Response.Write filename & " (" & File.Size &" bytes) was sent.<BR>"
else
Response.Write filename & " exceeded the maximum file size of " & maxbytes & " bytes."
end if
CASE "jpeg"
if File.Size < maxbytes then
sendMail = true
MyCDONTSMail.AttachFile File.Path
Response.Write filename & " (" & File.Size &" bytes) was sent.<BR>"
else
Response.Write filename & " exceeded the maximum file size of " & maxbytes & " bytes."
end if
CASE ".png"
if File.Size < maxbytes then
sendMail = true
MyCDONTSMail.AttachFile File.Path
Response.Write filename & " (" & File.Size &" bytes) was sent.<BR>"
else
Response.Write filename & " exceeded the maximum file size of " & maxbytes & " bytes."
end if
CASE ELSE
Response.Write "File '" & filename & "' was not of a valid type.<br>"
END SELECT
next
 
if sendmail = true then
MyCDONTSMail.Send
set MyCDONTSMail=nothing
response.Write "<br>Thank you - your email was sent.<br>"
end if
'clean up server AFTER mail is sent
for each File in upload.Files
deleteFile File.Path
next
Set Upload = Nothing
else
 
%>
 
<FORM METHOD="POST" ENCTYPE="multipart/form-data" ACTION="contact-me.asp?up=1">
<INPUT TYPE="FILE" SIZE="40" NAME="FILE1" ID="File1"><BR>
<INPUT TYPE="FILE" SIZE="40" NAME="FILE2" ID="File2"><BR>
<INPUT TYPE="FILE" SIZE="40" NAME="FILE3" ID="File3"><BR>
Your email: <input type="text" name="email"><br>
Message:<br>
<textarea name="message" rows="6" cols="40"></textarea>
<INPUT TYPE=SUBMIT VALUE="GO" NAME="Submit1">
</FORM>
 
<%
end if
%>
[+][-]03/22/09 10:54 PM, ID: 23955070Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/22/09 10:56 PM, ID: 23955079Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/22/09 11:40 PM, ID: 23955209Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/22/09 11:43 PM, ID: 23955221Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/22/09 11:57 PM, ID: 23955257Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/23/09 12:17 AM, ID: 23955323Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/23/09 12:36 AM, ID: 23955386Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/23/09 02:17 AM, ID: 23955730Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/23/09 03:44 PM, ID: 23963022Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/23/09 09:06 PM, ID: 23964610Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/23/09 10:25 PM, ID: 23964965Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/23/09 11:15 PM, ID: 23965176Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/23/09 11:26 PM, ID: 23965204Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091118-EE-VQP-93 - Hierarchy / EE_QW_3_20080625