|
Posted by Erik Lautier on 12/16/06 00:48
Hello, I'm using a multipart/form-data upload to put an image into SQL
Server, and it appears to be working, but I'm unable to display the
image. All I'm getting is the text of the URL we're on in Firefox and
a missing image icon in IE! Any ideas why this isn't working? Here's
the image upload code:
Dim intImageSize As Int64
Dim strImageType As String
Dim ImageStream As Stream
intImageSize = Picture.PostedFile.ContentLength
strImageType = Picture.PostedFile.ContentType
ImageStream = Picture.PostedFile.InputStream
Dim ImageContent(intImageSize) As Byte
Dim intStatus As Integer
intStatus = ImageStream.Read(ImageContent, 0, intImageSize)
'make connection, write SPs, open connection, etc.
Try
dbComm.ExecuteNonQuery()
Connect.close
Catch SQLexc As SqlException
Response.Write("Insert Failed. Error Details are: " &
SQLexc.ToString())
End Try
--------------
And now the display code:
'make connection, then SELECT Image, Imagetype FROM Pets WHERE
[User]=@user AND Petn=@petn
'stored procedures
Dim Reader As SqlDataReader
Reader = dbComm.ExecuteReader(CommandBehavior.CloseConnection)
If Reader.read=True Then
Response.ContentType = Reader(1)
Response.BinaryWrite(Reader(0))
Else
End If
Reader.close
Connect.close
----------------------------
Thanks.
[Back to original message]
|