locked
I can save, but not retreive an image.... RRS feed

  • Question

  • User1082171052 posted
    Edited by SomeNewKid. Please place code between <color="#000000"><</color>code> and <color="#000000"><</color>/code> tags.
    Hi there. Using: ASP.NET(vb), SQL Server 2000, Windows XP. Currently: I can save to the DB using this code:: Public Sub uploadImage() Dim fs As New FileStream(imgUploaded.ImageUrl, FileMode.OpenOrCreate, FileAccess.Read) Dim MyData(fs.Length) As Byte fs.Read(MyData, 0, fs.Length) Dim lclObjImageData As New cxImageData With lclObjImageData .imageName = ImageTitle.Text .imageType = ImageFile.PostedFile.ContentType fs.Read(MyData, 0, fs.Length) .image = MyData End With mObjDataAccess.uploadImage(lclObjImageData) Response.Redirect("ImageUpload.aspx") End Sub But, now how can I get the image, but put it in an Image Object?? I hav already done the Response.Write, but that just places it on a new page. I really could use some help. Thanks in advance...
    Tuesday, June 22, 2004 10:52 AM

All replies

  • User-1372641848 posted
    ::how can I get the image, but put it in an Image Object. if you have byte[] buffer created from input file. then you can use following c# code to convert it to System.Drawing.Image object MemoryStream ms = new MemoryStream(); ms.Write(buffer, 0, buffer.Length); System.Drawing.Bitmap imgIn = new System.Drawing.Bitmap(ms); I hope i have understood your problem.
    Tuesday, June 22, 2004 8:13 PM
  • User1082171052 posted
    seems close, but I am using ASP.NET + VB. Not sure if that C# code can be done the same way in VB. I guess my problem is that from the database, I can write the stream to the response objects output buffer. OK Cool, but how could I get that to go into a stream. The problem is that with the save method I have, the FileStream needs a string value to get the image into the stream itself. When coming from the DB, its binary data, and I am not sure how to cast that into a string val. But then, a string is not a binary stream of bytes, so that cast will not work. Its a real headscratcher. BTW, thanks for the reply :)
    Wednesday, June 23, 2004 11:09 AM
  • User-1372641848 posted
    ::Not sure if that C# code can be done the same way in VB C# and vb.net uses same framework classes. Can you explain again what you are trying to achive? like from where your datacomes? (binary byte[] from database, user uploaded file), what you want to do with that data? (save it on filesystem,stream to user,save to database)
    Wednesday, June 23, 2004 1:53 PM
  • User-1372641848 posted
    ::Not sure if that C# code can be done the same way in VB C# and vb.net uses same framework classes. Can you explain again what you are trying to achive? like from where your datacomes? (binary byte[] from database, user uploaded file), what you want to do with that data? (save it on filesystem,stream to user,save to database)
    Wednesday, June 23, 2004 2:02 PM
  • User-172932915 posted
    When I deal with image uploads and db's, I generally put the file in a folder on the server, and put the filename in the database. To get the image all you need is the path to the images folder and the images name.
    Tuesday, July 13, 2004 12:11 AM