Read Method of ASPForm class

Method | Member of  ScriptUtils.ASPForm | Changes | Purchase | Download

Description

Reads source form data from the client using Request.BinaryRead
You can use this method to cause ASPForm read source data in special error cases, especially when fsSizeLimit error occurs. You can read part of source data with first n fields

Syntax

ASPForm.Read ([NumberOfBytesToRead as Long = -1 = SizeLimit], [NumberOfFieldsToRead as Long = -1 = All source fields])
 

Where Type Optional Default Description
 NumberOfBytesToRead  Long  yes  -1 = SizeLimit  Maximum number of bytes to read 
 NumberOfFieldsToRead  Long  yes  -1 = All source fields  Maximum number of source form fields to read 

Remarks

You do not need to call this method explicitly.
This method is called by default when next Form method/property is called:
ScriptUtils.ASPForm.Items
ScriptUtils.ASPForm.Files
ScriptUtils.ASPForm.Texts
ScriptUtils.ASPForm.SourceData
ScriptUtils.ASPForm.State
_NewEnum (For Each ... in Form)

Examples

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 'completed
  '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>

POST, ASPForm - Work with original posted data.

Other links for Read

Methods of ASPForm class

AddConnection, CancelConnection, CheckRequirements, Read, Sleep, StringToBinary

Properties of ASPForm class

BytesRead, Files, FormType, getForm, CharSet, ChunkReadSize, Items, MaxMemoryStorage, NewUploadID, ReadTime, ReadTimeout, SizeLimit, SourceData, State, TempPath, Texts, ThreadPriority, TotalBytes, UploadID

ScriptUtils.ASPForm

The ASPForm collection retrieves the values of form elements posted to ASP script by a form using the POST method. ASPForm can process multipart/form-data or application/x-www-form-urlencoded data with length up to 2GB.

ScriptUtils

Huge ASP upload is easy to use, hi-performance ASP file upload component with progress bar indicator. This component lets you upload multiple files with size up to 4GB to a disk or a database along with another form fields. Huge ASP file upload is a most featured upload component on a market with competitive price and a great performance . The software has also a free version of asp upload with progress, called Pure asp upload , written in plain VBS, without components (so you do not need to install anything on server). This installation package contains also ScriptUtilities library. Script Utilities lets you create hi-performance log files , works with binary data , you can download multiple files with zip/arj compression, work with INI files and much more with the ASP utility.

© 1996 - 2011 Antonin Foller, Motobit Software | About, Contacts | e-mail: info@pstruh.cz


Other Motobit links:   IISTracer, real-time IIS monitor   ASP file upload - upload files to ASP. 
ActiveX/VBSScript registry editor  ActiveX NT User account manager  Export MDB/DBF from ASP Active LogFile  Email export  ActiveX/ASP Scripting Dictionary object