Upload - cause read when source data exceeds a limit | ||
| Sample for ScriptUtils.ASPForm.Read |
| Upload - cause read when source data exceeds a limit | |
|---|---|
<%
'Stores only files with size less than MaxFileSize
Dim DestinationPath
DestinationPath = Server.MapPath("UploadFolder")
'Create a form object
Dim Form: Set Form = Server.CreateObject("ScriptUtils.ASPForm")
'Set script timeout and maximum form limit
Server.ScriptTimeout = 2000
Form.SizeLimit = &H100000 '1MB
If Form.State = 0 Then 'Completted
'process source data
Form.Files.Save DestinationPath
Response.Write "<br><Font Color=green>Files (" & Form.TotalBytes \1024 _
& "kB) was saved to " & DestinationPath & " folder.</Font>"
ElseIf Form.State > 10 Then
'Check error states
Const fsSizeLimit = &HD
Select Case Form.State
Case fsSizeLimit:
'check some fields if source data exceeds limit
'Cause read at least 3 source fields, maximum of 100kB
'ASPForm will read text1, check1 and hidden1 fields
Form.Read 100000,3
If Form.State <10 Then
'Source fields was read.
Response.Write "<br>Number of read source form fields: " & _
Form.Fields.Count
Response.Write "<br>Number of read source bytes: " & _
Form.BytesRead
Response.Write "<br>Text1 value: " & _
Form("Text1")
Response.Write "<br>Hidden1 value: " & _
Form("Hidden1")
End If
Response.Write "<br><Font Color=red>Source form size (" & _
Form.TotalBytes & "B) exceeds form limit (" & _
Form.SizeLimit & "B)</Font><br>"
'Why MS means that 'friendly' error messages are friendly???
Response.Write Space(5555)
Case Else Response.Write "<br><Font Color=red>Some form error.</Font><br>"
End Select
End If'Form.State = 0 then
%>
<!DOCTYPE HTML Public "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<TITLE>ASP huge file upload, cause read In
a special Case - source data exceeds a limit.</TITLE>
</HEAD>
<BODY BGColor=white>
<Div style=width:600>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TR>
<TH noWrap align=Left width="20%" bgColor=khaki> <A
href="https://www.motobit.com/help/scptutl/upload.asp">Power ASP
file upload</A>, cause read In a special Case -
source data exceeds a limit. </TH>
<TD> </TD></TR></TABLE>
<TABLE cellSpacing=2 cellPadding=1 width="100%" bgColor=white border=0>
<TR>
<TD colSpan=2>
<P> This sample demonstrates reading
part of a source data (text, hidden And checkbox fields)
when source data size exceeds a form limit.<br>
You can cause form To read
specified number of source fields with maximum size, Or specified number
of source bytes. You can Loop through source fields collection,
work with fields And read field values as with standard form Then.
<br>Upload timeout Is <%=Server.ScriptTimeout%>s
<br>Form size limit Is <%=Form.SizeLimit \ 1024 %>kB
<br>Destination folder Is <%=DestinationPath%>
</P>
</TD></TR></TABLE>
<form method="POST" ENCTYPE="multipart/form-data">
Text : <input name="Text1" value="Some text value 1"><br>
Check1 : <input name="Check1" value="1" Type=CheckBox>Some checkbox<br>
Hidden : <input type="hidden" name="Hidden1" value="Some hidden value"><br>
File 1 : <input type="file" name="File1"><br>
File 2 : <input type="file" name="File2"><br>
File 3 : <input type="file" name="File3">
<br>
<input Name=SubmitButton Value="Upload files >>" Type=submit><br>
</Form>
<HR COLOR=silver Size=1>
<CENTER>
<FONT SIZE=1>© 1996 – <%=Year(Date)%> Antonin Foller, <a
href="http://www.motobit.com">PSTRUH Software</a>, e-mail <A
href="mailto:help@pstruh.cz" >help@pstruh.cz</A>
<br>To monitor current running uploads/downloads, see <A
Href="https://www.motobit.com/help/iistrace/iis-monitor.asp">IISTracer
- IIS real-Time monitor</A>.
</FONT>
</CENTER>
</Div>
</BODY></HTML> | |