How to open a image which is stored in server

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rohitbce
    New Member
    • Aug 2007
    • 30

    How to open a image which is stored in server

    Hi
    I am saved my Document in server By the follwing code

    coding......... ...


    If fupLoadDoc.HasF ile Then
    Dim reader As BinaryReader = New BinaryReader(fu pLoadDoc.Posted File.InputStrea m)
    Dim byt() As Byte = reader.ReadByte s(fupLoadDoc.Po stedFile.Conten tLength)
    ''objVLEAttache Doc.Documentimg = byt
    dtDoc.Rows(intr r).Item(3) = byt
    objVLEAttacheDo c.Documentimg = dtDoc.Rows(intr r).Item(3)
    Else
    dtDoc.Rows(intr r).Item(3) = System.DBNull.V alue
    objVLEAttacheDo c.Documentimg = dtDoc.Rows(intr r).Item(3)
    End If

    This save the Document on the server successfully
    now problem is that i want to open that document
    so how can i ............... .
    plz help me............. ............... .
    Rohit Jain
  • rohitbce
    New Member
    • Aug 2007
    • 30

    #2
    its Urgent plz help me
    Rohit

    Comment

    • Shashi Sadasivan
      Recognized Expert Top Contributor
      • Aug 2007
      • 1435

      #3
      I havent done this, but u need to convert the bytestream (the blob) back to an image type...
      have you searched for anything similar?

      got something which might be of interest to you
      Code:
      OracleBlob blob = reader.GetOracleBlob(0);
       
      Bitmap image = new Bitmap(blob);
      pictureBox1.Image=image;
      cheers

      Comment

      • rohitbce
        New Member
        • Aug 2007
        • 30

        #4
        Originally posted by Shashi Sadasivan
        I havent done this, but u need to convert the bytestream (the blob) back to an image type...
        have you searched for anything similar?

        got something which might be of interest to you
        Code:
        OracleBlob blob = reader.GetOracleBlob(0);
         
        Bitmap image = new Bitmap(blob);
        pictureBox1.Image=image;
        cheers
        Thanks for your valuable response
        i am useing sql and convert it like that but not getting how to get the path
        Session("txtsca n") = ObjData1.Tables (0).Rows(IntCou nter1).Item(0)
        Dim byt() As Byte = CType(ObjData1. Tables(0).Rows( IntCounter1).It em(0), Byte())
        Dim bmpimg As Bitmap
        Dim mstream As New MemoryStream
        mstream.Write(b yt, 0, byt.Length)
        I am not using any picture box instead of this i am using like an website we open the attachment i have done like that that working but when i am open a file from server it's not working ...............


        Dim TargetFile As FileInfo
        TargetFile = New System.IO.FileI nfo(ViewState(" Path"))
        Response.Clear( )

        Response.AddHea der("Content-Disposition", "attachment ; filename=" + TargetFile.Name )

        Response.AddHea der("Content-Length", TargetFile.Leng th.ToString())

        Response.WriteF ile(TargetFile. FullName)

        Response.End()
        Rohit

        Comment

        Working...