ByteArray Property, read only of FormField class

Property, read only | Member of  ScriptUtils.FormField | Changes | Purchase | Download

Description

Contents of a source field as a byte array (VT_UI1 | VT_ARRAY)

Syntax

vByteArray = FormField.ByteArray ([Start as Long = Start of field], [Length as Long = Length of field])
 

Where Type Optional Default Description
 Start  Long  yes  Start of field  Start position to return binary data 
 Length  Long  yes  Length of field  Length of source data to return 

Returns

Variant

Examples

Upload - Upload of large files to database using AppendChunk method of RecordSet

Upload - Simple upload to database

<%
'Sample file db-bytearay.asp 
'Simple upload to database.
'Suitable for small files - up to 20% of physical server memory
'This sample works with any connection - MDB (JetOLEDB, ODBC)
' MS SQL (MSDASQL/ODBC) etc.

Server.ScriptTimeout = 240
'Simple upload to database

Dim Form: Set Form = Server.CreateObject("ScriptUtils.ASPForm")

'was the Form successfully received?
If Form.State = 0 Then

  Dim Conn, RS
  'Open connection to database
  Set Conn = GetConnection 
  Set RS = Server.CreateObject("ADODB.Recordset")

  'Open dynamic recordset, table Upload
  RS.Open "Upload", Conn, 2, 2
  RS.AddNew

    'Store extra form info.
    RS("Description") = Form("Description")
    RS("Title") = Form("Title")

    'Add file from source field 'DBFile' to table field 'Data'
    RS("Data") = Form("DBFile").ByteArray

    'Store technical informations
    RS("ContentType") = Form("DBFile").ContentType
    RS("SouceFileName") = Form("DBFile").FileName
    RS("DataSize") = Form("DBFile").Length

    RS("UploadDT") = Now()
  RS.Update
  RS.Close
  Conn.Close
End If'Form.State = 0 then

Function GetConnection()
  Dim Conn: Set Conn = CreateObject("ADODB.Connection")
  Conn.Provider = "Microsoft.Jet.OLEDB.4.0"
  Conn.Open "Data Source=" & Server.MapPath("upload.mdb") 
	Set GetConnection = Conn
End Function

Function CreateUploadTable(Conn)
  'This function creates upload table for MSSQL 6.5/7.0/2000
  Dim SQL
  SQL = SQL & "CREATE TABLE Upload ("
  SQL = SQL & "	UploadID int IDENTITY (1, 1) NOT NULL ,"
  SQL = SQL & "	UploadDT datetime NULL ,"
  SQL = SQL & "	RemoteIP char (15) NULL ,"
  SQL = SQL & "	ContentType char (64) NULL ,"
  SQL = SQL & "	SouceFileName varchar (255) NULL ,"
  SQL = SQL & "	Title varchar (255) NULL ,"
  SQL = SQL & "	Description text NULL ,"
  SQL = SQL & "	Data image NULL "
  SQL = SQL & ")"
  Conn.Execute SQL
End Function

%>  
Simple upload To database, sample For <A Href=http://www.motobit.com>HugeASP upload</A>.<br>
Suitable For small files - up To 20% of physical server memory<br>

<Table><form method=post ENCTYPE="multipart/form-data">
<TR>
 <TD></TD>
 <TD Align=Right><input type="submit" Name="Action" value="Upload the file >>"></TD>
</TR>
<TR>
 <TD>File To upload</TD>
 <TD><input type="file" name="DBFile"></TD>
</TR>
<TR>
 <TD>Title</TD>
 <TD><input size="60" name="Title" value="Title of the file."></TD>
</TR>
<TR>
 <TD>Description</TD>
 <TD><textarea cols="60" rows="8" name="Description">Type description of the file.</textarea></TD>
</TR>

</form></Table>

See also

FormField.String, FormField.HexString

Other links for ByteArray

Methods of FormField class

ContentCharSet, Save, SaveAs

Properties of FormField class

ByteArray, ContentDisposition, ContentTransferEncoding, ContentType, FileExt, FileName, FilePath, Header, Headers, HexString, CharSet, Index, InProgress, IsFile, Length, Name, RAWHeader, SourceLength, String, Value

ScriptUtils.FormField

One form field. Member of FormFields collection.

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