By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,760 Members | 969 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,760 IT Pros & Developers. It's quick & easy.

Pure ASP Upload - script unable to redirect for larger files

P: n/a
I'm working with 'pure ASP upload' script which is designed to
redirect to an alert/error message, should
a file larger than the set limit be attempted to be uploaded. The
problem is that, while smaller files do upload
successfully, the script does not catch the larger files and rather
than a specific error message in Firefox (and IE7), I just get the
The connection was reset
The connection to the server was reset while the page was loading.
* The site could be temporarily unavailable or too busy. Try
again in a few
* If you are unable to load any pages, check your computer's
* If your computer or network is protected by a firewall or
proxy, make sure
that Firefox is permitted to access the Web.
here's the script (below) for the database upload. Thanks for any
help or resources.
Kind Regards,

'Simple upload to database.
'Suitable for small files - up to 20% of physical server memory
'This sample works with any connection - MDB (JetOLEDB, ODBC)

'Server.ScriptTimeout = 240
'Simple upload to database

Dim Form: Set Form = New ASPForm %>
<!--#include virtual="/common/upload/_upload.asp"-->

Server.ScriptTimeout = 1000
Form.SizeLimit = 1024*1024*10'10MB
MaxFileSize = Form.SizeLimit

'was the Form successfully received?
Const fsCompletted = 0

If Form.State = fsCompletted Then 'Completted

dim objConnection, RS
'Open connection to database
Set objConnection = GetConnection
Set RS = Server.CreateObject("ADODB.Recordset")
'Open dynamic recordset, table Upload
RS.Open "AMS_ContentOverviewLecture", objConnection, 2, 2
'One-block assigning/AppendChunk is suitable for small files
'(<20% physical server memory). Plese see documentation to store
'10th megabytes or more in database.

'Add file from source field 'SourceFile' to table field 'Data'
'Store extra form info.
RS("CourseID") = Form("strCourseID")
RS("WeekNum") = Form("strWeekNum")
RS("MainTopicNum") = Form("strMainTopicNum")
'Add file from source field 'SourceFile' to table field 'Data'
RS("image_blob") = Form("SourceFile").ByteArray
'Store technical informations
RS("ContentType") = Form("SourceFile").ContentType
RS("filename") = Form("SourceFile").FileName

RS("filesize") = Form("SourceFile").Length

strFolderPath = strFolderPath&strFileName
RS("FolderPath") = strFolderPath

ElseIf Form.State 10 then
Const fsSizeLimit = &HD
Select case Form.State
case fsSizeLimit: response.status = "413 Request Entity Too Large"
response.write "<script type=""text/javascript"">alert (""Source
form size (" & Form.TotalBytes & "B) exceeds form limit (" &
Form.SizeLimit & "B) (10MB) \n The file was NOT uploaded"")</script>"
'Server.Transfer(Request.ServerVariables("PATH_INF O") & "?" &
case else response.write "<br><Font Color=red>Some form error.</
end Select
End If
Aug 18 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.