Upload - Using a HexString property and Insert statement | |
---|---|
<% 'Sample file db-HexString.asp 'Upload to MS SQL database, store file using HexString method and Insert statement 'Suitable for upload of small files (up to 20% of memory) ' and MS SQL databse (MS SQL 6.5 - MS SQL 2000) Server.ScriptTimeout = 36000 'Upload large files to MS SQL Server using HexString Dim d: D="" & time: d=Replace(d,":","") 'CreateUploadTable GetConnection Dim Form: Set Form = Server.CreateObject("ScriptUtils.ASPForm") Form.TempPath = "h:\temp" 'was the Form successfully received? If Form.State = 0 Then Dim Conn, SQL, RS, UploadID 'Open connection to database Set Conn = GetConnection 'Create template of insert statement SQL = "SET NOCOUNT ON Insert into Upload(UploadDT, ContentType, SouceFileName, Title, [Description], Data) values(" SQL = SQL & "GetDate()" SQL = SQL & ", '" & Form("DBFile").ContentType & "'" SQL = SQL & ", '" & Form("DBFile").FileName & "'" SQL = SQL & ", '" & Form("Title") & "'" SQL = SQL & ", '" & Form("Description") & "'" SQL = SQL & ",0x%s)" & vbCrLf SQL = SQL & "Select @@IDENTITY as UploadID" 'Write source file to the Insert statement as a HexString SQL = Replace(SQL, "%s", Form("DBFile").HexString) ' Set RS = Conn.Execute(SQL) UploadID = RS("UploadID") RS.Close Conn.Close Else Response.Write "<br>Form.State:" & Form.State End If'Form.State = 0 then Function GetConnection1() 'Open connection to MDB using Microsoft.Jet.OLEDB.4.0 Dim Conn: Set Conn = CreateObject("ADODB.Connection") Conn.Provider = "Microsoft.Jet.OLEDB.4.0" Conn.CommandTimeout = 1800 Conn.Open "Data Source=" & Server.MapPath("upload.mdb") Set GetConnection = Conn End Function Function GetConnection() 'Open connection to MS SQL using SQLOLEDB Dim Conn: Set Conn = CreateObject("ADODB.Connection") Conn.Provider = "SQLOLEDB" Conn.Open "Data Source=(local);Database=Upload", "sa", "" Set GetConnection = Conn End Function Function CreateUploadTable(Conn) 'This function creates upload table for MSSQL 6.5/7.0 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 %> <br>Upload To MS SQL database, store file using HexString method And Insert statement <br>sample For <A Href=http://www.motobit.com>HugeASP upload</A> <br>Suitable For upload of small files (up To 20% of memory) And MS SQL databse (MS SQL 6.5 - MS SQL 2000) <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> |
One form field. Member of FormFields collection.
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