I downloaded Pure ASP file upload from
www.motobit.com and used a script from pantyboy's Q at
http://www.experts-exchange.com/Web_Development/Software/Macromedia_Dreamweaver/Q_22482550.html but when I try it I get a blank page.
Am I missing something?
Script
~~~~~~~~~~~~~~~~~
<%
' Sample file Form-Email.asp
' Let's you send one an email with one or more attachments.
' Original code from
http://www.motobit.com/help/scptutl/upload.asp' Alteration of code to use CDOSYS instead of CDONTS by fuzzboxer at Experts Exchange
' See
http://www.experts-exchange.com/Web_Development/Software/Macromedia_Dreamweaver/Q_22482550.html'Global declarations.
'Get temporary folder
Dim ResultHTML
'Create upload form
'Using Huge-ASP file upload
'Dim Form: Set Form = Server.CreateObject("Scrip
tUtils.ASP
Form")
'Using Pure-ASP file upload
Dim Form: Set Form = New ASPForm %><!--#INCLUDE FILE="_upload.asp"--><%
Server.ScriptTimeout = 1000
'Do not upload data greater than 10MB.
Form.SizeLimit = &HA00000
'Progress bar window will receive the same ID.
Form.UploadID = Request.QueryString("Uploa
dID")'{/b}
Const fsCompletted = 0
If Form.State = fsCompletted Then 'Completted
ResultHTML = ProcessForm
ElseIf Form.State > 10 then
Const fsSizeLimit = &HD
Select case Form.State
case fsSizeLimit: ResultHTML = "<br><Font Color=red>Source form size (" & Form.TotalBytes & "B) exceeds form limit (" & Form.SizeLimit & "B)</Font><br>"
case else ResultHTML = "<br><Font Color=red>Some form error.</Font><br>"
end Select
End If
if request.QueryString("Actio
n") = "Cancel" then
ResultHTML = "<br><b>Upload was cancelled</b>"
end if
Function TempFolder()
Dim FS
Set FS = CreateObject("Scripting.Fi
leSystemOb
ject")
'Get temporary folder
TempFolder = FS.GetSpecialFolder(2) & "\emailtemp"
End Function
Sub DeleteFile(FileName)
Dim FS
Set FS = CreateObject("Scripting.Fi
leSystemOb
ject")
FS.DeleteFile FileName
End Sub
Function ProcessForm
Dim eName, eAddress, ePostcode, ePhone, eMail, eStory
'get source form fields - From, To, Subject, Message etc.
eName = Form("Name")
eAddress = Form("Address")
ePostcode = Form("PostCode")
ePhone = Form("PhoneNumber")
eMail = Form("EmailAddress")
eStory = Form("Story")
Dim HTML
HTML = "<br><span style='color:red'>Server-s
ide ASP script accepted source form with fields and files and email object was created. "
HTML = HTML & "<br>From: <b>" & eName & "</b>"
HTML = HTML & "<br>Address: <b>" & eAddress & "</b>"
HTML = HTML & "<br>Postcode: <b>" & ePostcode & "</b>"
HTML = HTML & "<br>Phone: <b>" & ePhone & "</b>"
HTML = HTML & "<br>Email: <b>" & eMail & "</b>"
HTML = HTML & "<br>Story: <b>" & eStory & "</b>"
Dim objNewMail, File, FileName
'Create a new email message
Set objNewMail = CreateObject("CDO.Message"
)
objNewMail.To = "name@domain.com" ' Change this to your recipient
objNewMail.From = "name@domain.com" ' Change this to your poster
objNewMail.Subject = "From the Website" ' Change this to your subject line
'Save source files to temporary folder
'Add these files to the new e-mail
HTML = HTML & "<br>Attachments:"
For Each File In Form.Files.Items
'If source file is specified.
If Len(File.FileName) > 0 Then
HTML = HTML & "<br> " & File.Name & ": <b>" & File.FileName & ", " & File.Length \ 1024 & "kB</b>"
FileName = TempFolder & "\" & File.FileName
File.SaveAs FileName
objNewMail.AddAttachment FileName
End If
Next
'Send the new email
objNewMail.HtmlBody = HTML
objNewMail.Send
Response.Redirect("ThankYo
u.asp") ' Change this to your page name
Set objNewMail=nothing
'delete temporary files
For Each File In Form.Files.Items
If Len(File.FileName) > 0 Then
FileName = TempFolder & "\" & File.FileName
on error resume next
DeleteFile FileName
End If
Next
HTML = HTML & "</Font><br>"
ProcessForm = HTML
End Function
'{b}get an unique upload ID for this upload script and progress bar.
Dim UploadID, PostURL
UploadID = Form.NewUploadID
'Send this ID as a UploadID QueryString parameter to this script.
PostURL = Request.ServerVariables("S
CRIPT_NAME
") & "?UploadID=" & UploadID'{/b}
%>
Start Free Trial