Class: SoftArtisans.FileUp
Method: SaveAsBlob ([in] recordset("column-name"))
Description: This method saves an uploaded file to a database.
The recordset must point to a valid ADO Field object that supports the AppendChunk method. Any OLEDB provider that supports the AppendChunk method can be the destination of a SaveAsBlob. SA-FileUp uses late binding to find the AppendChunk method of the recordset member and writes the data using this method. Note that even char and varchar type fields support AppendChunk, except that the size is significantly limited.
For Microsoft SQL Server, the column should be 'image' type. There is a sample SQL script included with this distribution that can be used to create tables for use in uploading files.
For Microsoft Access, the column should be 'OLE Object'. There is a sample Access database included with this distribution that can be used for uploading files.
When writing to blob fields, the ADO Recordset's cursor type must be adOpenDynamic ( = 2).
Any size limitations of the blob field less than 2 GB is imposed by the database. The maximum uploaded file size supported by SA-FileUp is still 2 GB.
The uploaded data is stored exactly as sent, with no interpretation. (Early betas of version 2 stored the information in Unicode format, but this was deemed unnecessary).
If there is more than one file being uploaded in a single page, only the first one will be saved.
To save multiple files in a single upload, there is an equivalent method for each file object, i.e. upl.Form("FILE1").SaveAsBlob rs("filecol").
In general, uploading to a database instead of a file is less efficient, both in terms of disk space and processor time. Due to the caching necessary when processing multiple form and file elements, the upload is saved to a file and then imported into the database. The temporary cache file is then deleted. Uploading to a database also consumes significant memory resources. It is possible that you will get
"There is insufficient system memory to run this query"
errors when uploading to a database. Uploading to a database is best when there are many small files that you wish to catalogue, such as small graphic images. Large uploads are preferably stored in native files.
<%
set rsBlob = Server.CreateObject("adodb.recordset")
rsBlob.Open "SimpleBlobTable", "AccessUpload", 2, 3
'---
'--- Add new record and update
'---
rsBlob.AddNew
upl.SaveAsBlob rsBlob.Fields("filecol")
rsBlob.Update
rsBlob.Close
Set rsBlob = Nothing
... %>