Hi Shawn,
Try to clear the response object after the following code:
Response.Buffer = True
Response.Expires = -1
Response.ClearContent()
Response.ClearHeaders()
// Clear the response object.
Response.Clear();
And then when you finished writing into the response stream:
Response.Flush();
Response.End();
I think it might help.
See ya.
Thiago Oliveira
escreveu:
> hi there
>
> i have the following bit of code that downloads/uploads documents from
> a sql database.
>
> the problem i have is when i download an image for example and look at
> it in notepad i see the binary data and below it the html from the page
> the image was downloaded from. so my 10k image is now 32k.
>
> please any help would be much appreciated.
>
> thanks
>
> shawn
>
>
>
> Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles btnUpload.Click
> Dim iLength As Integer =
> CType(LifeFileUpload.PostedFile.InputStream.Length , Integer)
> If iLength = 0 Then Exit Sub 'not a valid file
> Dim sContentType As String =
> LifeFileUpload.PostedFile.ContentType
> Dim sFileName As String, i As Integer
> Dim bytContent As Byte()
> ReDim bytContent(iLength)
>
> 'strip the path off the filename
> i = InStrRev(LifeFileUpload.PostedFile.FileName.Trim, "\")
> If i = 0 Then
> sFileName = LifeFileUpload.PostedFile.FileName.Trim
> Else
> sFileName = Right(LifeFileUpload.PostedFile.FileName.Trim,
> Len(LifeFileUpload.PostedFile.FileName.Trim) - i)
> End If
>
> LifeFileUpload.PostedFile.InputStream.Read(bytCont ent, 0,
> iLength)
>
> objDonkey.SelectedClient.AddDocument(objDonkey.Use rName,
> sFileName, sContentType, iLength, bytContent, "this is a test
> document")
>
>
> End Sub
>
> Protected Sub btnGetDoc_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles btnGetDoc.Click
> Dim DocId As Integer
> Dim objDoc As Life.Clients.Client.DocumentItem
>
> DocId = HiddenSelectedDoc.Value
> objDonkey.SelectedClient.GetDocuments()
> objDoc = objDonkey.SelectedClient.DocumentList(DocId)
>
>
> Response.Buffer = True
> Response.Expires = -1
> Response.ClearContent()
> Response.ClearHeaders()
>
> Response.ContentType = "image/jpeg" 'objDoc.ContentType
>
> Response.OutputStream.Write(CType(objDonkey.Select edClient.GetDocument(DocId),
> Byte()), 0, CInt(objDoc.ContentLegnth))
> Response.AddHeader("Content-Disposition",
> "attachment;filename=" + objDoc.Filename)
> Response.Flush()
>
>
> End Sub