Got more questions? Find advice on: SQL | XML | Regular Expressions | Windows
in Search
Welcome to AspAdvice Sign in | Join | Help

Image Viewing problem

Last post 06-23-2009, 4:35 AM by ninofresh. 0 replies.
Sort Posts: Previous Next
  •  06-23-2009, 4:35 AM 54226

    Image Viewing problem

    I use the following code to save two images to a db from a file upload control

     Try
                Me.RequiredFieldValidator39.Enabled = False
                Me.RequiredFieldValidator40.Enabled = False
                If Me.FileUpload1.PostedFile Is Nothing OrElse String.IsNullOrEmpty(FileUpload1.PostedFile.FileName) OrElse FileUpload1.PostedFile.InputStream Is Nothing Then
                    photo = New Byte() {0}
                Else
                    Dim extension As String = Path.GetExtension(FileUpload1.PostedFile.FileName).ToLower()
                    Dim MIMEType As String = Nothing
                    Select Case extension
                        Case ".gif"
                            MIMEType = "image/gif"
                        Case ".jpg", ".jpeg", ".jpe"
                            MIMEType = "image/jpeg"
                        Case ".png"
                            MIMEType = "image/png"
                        Case Else
                            Me.lblerror.Text = "Only GIF, JPG, and PNG files can be uploaded to the picture album."
                            Exit Sub
                    End Select
                    Dim imageBytes(FileUpload1.PostedFile.InputStream.Length) As Byte
                    FileUpload1.PostedFile.InputStream.Read(imageBytes, 0, imageBytes.Length)
                    photo = imageBytes
                    Session("photo") = photo
                End If
                If Me.FileUpload2.PostedFile Is Nothing OrElse String.IsNullOrEmpty(FileUpload2.PostedFile.FileName) OrElse FileUpload2.PostedFile.InputStream Is Nothing Then
                    photo1 = New Byte() {0}
                Else
                    Dim extension1 As String = Path.GetExtension(FileUpload2.PostedFile.FileName).ToLower()
                    Dim MIMEType1 As String = Nothing
                    Select Case extension1
                        Case ".gif"
                            MIMEType1 = "image/gif"
                        Case ".jpg", ".jpeg", ".jpe"
                            MIMEType1 = "image/jpeg"
                        Case ".png"
                            MIMEType1 = "image/png"
                        Case Else
                            Me.lblerror.Text = "Only GIF, JPG, and PNG files can be uploaded to the picture album."
                            Exit Sub
                    End Select
                    Dim imageBytes(FileUpload2.PostedFile.InputStream.Length) As Byte
                    FileUpload2.PostedFile.InputStream.Read(imageBytes, 0, imageBytes.Length)
                    photo1 = imageBytes
                    Session("photo1") = photo1

                End If
                Session("NewRegNo") = Me.txtEsutRegNo.Text
                Insert3 = sqlclass.InsertPhoto(Me.txtEsutRegNo.Text, photo, photo1)
                Me.Image1.ImageUrl = "LoadPic.aspx?picid=" & Me.txtEsutRegNo.Text
                Me.Image2.ImageUrl = "LoadPic1.aspx?picid=" & Me.txtEsutRegNo.Text

     

    and the following codes to view the images from the LoadPic page

             Dim id As String
            id = Request.Params("picid")
            '   Dim arr As Byte()
            Try
                dr = sqlclass.getStudentPhoto(id)
                If dr.Read Then
                    Response.ContentType = "image/jpeg"
                    Response.BinaryWrite(dr.Item("Picture"))
                End If
            Catch ex As Exception

            End Try


    On my local  machine it works but when I publish the site and upload to my ftp site it doesnt show any idean on what could be the problem

    I need help ASAP. Thanks

View as RSS news feed in XML