Hi Vijay-
I found some code on the web for file upload and download.Right now to keep it simple I am not using any database. I am just uploading to the server and downloading from the server. The upload is working fine. However, for file download the dialog window is showing 2 times, I have to click on "Open" 2 times to actually open the pdf file. The "Save" option works fine. This is the only code in the imagebutton's click method. I am using an image button to view the file. Can you guess as to why clicking on open once does not work.
Private Sub ImageButton1_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click
Dim objFileInfo As System.IO.FileInfo
Dim strPhysicalPath As String
strPhysicalPath = Server.MapPath("docbox.pdf")
objFileInfo = New System.IO.FileInfo(strPhysicalPath)
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Response.AppendHeader("Content-Disposition", "attachment; filename" + objFileInfo.FullName)
Response.AddHeader("Content-Length", objFileInfo.Length.ToString())
Response.WriteFile(objFileInfo.FullName)
Response.Flush()
Response.End()
End Sub
Thanks!
|