|
[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. |
|
|
|
|
Asked by AvanteIT in Active Server Pages (ASP), Access Forms, WebObjects
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
%>
|
20091118-EE-VQP-93 - Hierarchy / EE_QW_3_20080625