Saving image file to sql server

Author Message
peach24

  • Total Posts : 7
  • Scores: 0
  • Reward points : 0
  • Joined: 6/9/2001
  • Location: USA
  • Status: offline
Saving image file to sql server Sunday, June 10, 2001 11:41 PM (permalink)
0
I try to make an asp/html page that allow user to upload file to blob
field in sql server.

please help.

 
#1
    aspprogrammer

    • Total Posts : 10
    • Scores: 0
    • Reward points : 0
    • Joined: 6/9/2001
    • Location: Belgium
    • Status: offline
    Re: Saving image file to sql server Sunday, June 10, 2001 11:42 PM (permalink)
    0


    the html would look something like:
    <FORM METHOD="POST" ACTION="Sample4.asp"
    ENCTYPE="multipart/form-data">
    <INPUT TYPE="FILE" NAME="FILE1" SIZE="50"><BR>
    <INPUT TYPE="FILE" NAME="FILE2" SIZE="50"><BR>
    <INPUT TYPE="FILE" NAME="FILE3" SIZE="50"><BR>
    <INPUT TYPE="FILE" NAME="FILE4" SIZE="50"><BR>
    <INPUT TYPE="SUBMIT" VALUE="Upload">
    </FORM>

    But you need a component to call in Sample4.asp to process the
    upload. Here's the Sample4.asp code:

    <HTML>
    <BODY BGCOLOR="white">

    <H1>aspSmartUpload : Sample 4</H1>
    <HR>

    <%
    ' Variables
    ' *********
    Dim mySmartUpload
    Dim file
    Dim oConn
    Dim oRs
    Dim intCount
    intCount=1

    ' Object creation
    ' ***************
    Set mySmartUpload =
    Server.CreateObject("aspSmartUpload.SmartUpload")

    ' Upload
    ' ******
    mySmartUpload.Upload

    ' Connect to the DB
    ' *****************
    Set oConn = openConnection( )
    'curDir = Server.MapPath("Sample.mdb")
    'oConn.Open "DBQ="& curDir &";Driver={Microsoft Access
    Driver (*.mdb)};DriverId=25;FIL=MS Access;"

    ' Open a recordset
    ' ****************
    strSQL = "SELECT RecordID, FileName, Type, [File] FROM
    tblFiles "

    Set oRs = Server.CreateObject("ADODB.recordset")
    'Set oRs.ActiveConnection = oConn
    'oRs.Source = strSQL
    oRs.LockType = 3

    Call oRs.Open( strSQL, oConn, adOpenDynamic,
    adLockPessimistic )

    ' Select each file
    ' ****************
    For each file In mySmartUpload.Files
    ' Only if the file exist
    ' **********************
    If not file.IsMissing Then

    ' Add the current file in a DB field
    ' **********************************
    oRs.AddNew
    file.FileToField oRs.Fields("File")
    oRs("FileName") = file.FileName
    oRS( "Type" ) = "tst"
    oRS( "RecordID" ) = intCount
    oRs.Update
    intCount = intCount + 1
    End If
    Next

    ' Display the number of files uploaded
    ' ************************************
    Response.Write(intCount & " file(s) uploaded.<BR>")

    ' Destruction
    ' ***********
    oRs.Close
    oConn.Close
    Set oRs = Nothing
    Set oConn = Nothing
    %>
    </BODY>
    </HTML>


    <%
    function openConnection()
    Dim objConnection

    set objConnection =
    Server.CreateObject("ADODB.Connection")
    objConnection.Provider = "SQLOLEDB"
    objConnection.Open "Source=dev1;UID=sa;PWD=;Initial
    Catalog=bcc1-military;"

    ' objConnection.Open Application("ConnectionString")

    set openConnection = objConnection
    end function
    %>
    The above is a quickie but you should really use sp's to talk to the
    db.

    I recommend the SmartASP component only because it is free !
    http://www.aspsmart.com

     
    #2

      Online Bookmarks Sharing: Share/Bookmark

      Jump to:

      Current active users

      There are 0 members and 1 guests.

      Icon Legend and Permission

      • New Messages
      • No New Messages
      • Hot Topic w/ New Messages
      • Hot Topic w/o New Messages
      • Locked w/ New Messages
      • Locked w/o New Messages
      • Read Message
      • Post New Thread
      • Reply to message
      • Post New Poll
      • Submit Vote
      • Post reward post
      • Delete my own posts
      • Delete my own threads
      • Rate post

      2000-2012 ASPPlayground.NET Forum Version 3.9