G
Guest
Hi
When the user clicks the download button on my aspx page, the file (pdf)
downloaded from my server another drive. Once he clicks the button, I
inserted the record on one of table. after that the IE will ask do you want
to open or cancel, the user may click cancel button. so in this situtation, i
need to insert the record on table once the user click save button. if the
user clicks the cancel, I should not insert the records. how to catch that
event. any idea?
and also i have the file name like "file, user.pdf". when using Firefox, its
just display the "file," on downloading window. is it any chance to resolve
this?
below is the code i am using for downlading the file.
thanks
bala
Private Sub DownloadFile(ByVal fname As String, ByVal forceDownload As
Boolean)
Dim path1 As String = fname
Dim name As String = Path.GetFileName(path1)
Dim ext As String = Path.GetExtension(path1)
'Dim type As String = "Application/pdf"
Response.ContentType = "Application/pdf"
If forceDownload Then
Response.AppendHeader("content-disposition", "attachment;
filename=" & name)
Else
Response.AppendHeader("content-disposition", "inline;
filename=" & name)
End If
Dim MyFileStream As FileStream
Dim FileSize As Long
MyFileStream = New FileStream(fname, FileMode.Open)
FileSize = MyFileStream.Length
Dim Buffer(CInt(FileSize)) As Byte
MyFileStream.Read(Buffer, 0, CInt(FileSize))
MyFileStream.Close()
Response.BinaryWrite(Buffer)
Response.End()
End Sub
When the user clicks the download button on my aspx page, the file (pdf)
downloaded from my server another drive. Once he clicks the button, I
inserted the record on one of table. after that the IE will ask do you want
to open or cancel, the user may click cancel button. so in this situtation, i
need to insert the record on table once the user click save button. if the
user clicks the cancel, I should not insert the records. how to catch that
event. any idea?
and also i have the file name like "file, user.pdf". when using Firefox, its
just display the "file," on downloading window. is it any chance to resolve
this?
below is the code i am using for downlading the file.
thanks
bala
Private Sub DownloadFile(ByVal fname As String, ByVal forceDownload As
Boolean)
Dim path1 As String = fname
Dim name As String = Path.GetFileName(path1)
Dim ext As String = Path.GetExtension(path1)
'Dim type As String = "Application/pdf"
Response.ContentType = "Application/pdf"
If forceDownload Then
Response.AppendHeader("content-disposition", "attachment;
filename=" & name)
Else
Response.AppendHeader("content-disposition", "inline;
filename=" & name)
End If
Dim MyFileStream As FileStream
Dim FileSize As Long
MyFileStream = New FileStream(fname, FileMode.Open)
FileSize = MyFileStream.Length
Dim Buffer(CInt(FileSize)) As Byte
MyFileStream.Read(Buffer, 0, CInt(FileSize))
MyFileStream.Close()
Response.BinaryWrite(Buffer)
Response.End()
End Sub