File Upload Error

G

Guest

I am facing some problem. I uploaded some different files (jpg, bmp, doc,
pdf) into SQL Database using ASP.NET and VB.NET and I tried to download them
again. all files worked properly unless the pdf files. The download goes fine
but when I try to open them, I receive an error declaring that the file is
corrupted and can not be read or even repaired. Their sizes are less than
some of word documents I uploaded and download them later so it has nothing
to do with the size. I don't know why?

If dr.Read Then
Response.ContentType = dr("ContentType").ToString
Response.OutputStream.Write(CType(dr("FileData"), _
Byte()), 0, CInt(dr("FileSize")))
Response.AddHeader("Content-Disposition", _
"attachment;filename=" + dr("FileName").ToString())
End if


I am using Visual Studio .NET 2005 Beta 1
 
S

Steve C. Orr [MVP, MCSD]

Be sure to call Response.Clear() before outputting the PDF data, and call
Response.End() right after.

This is to be sure that only the PDF data gets output and no other page
elements which will confuse the PDF viewer.

Also, some versions of Acrobat are more stable than others.

http://SteveOrr.net/articles/EasyUploads.aspx



I hope this helps,

Steve C. Orr,

MCSD, MVP

http://SteveOrr.net
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,815
Latest member
treekmostly22

Latest Threads

Top