Guest_imported
New member
- Jan 1, 1970
- 0
Hi,
I have the following problem.
I have 2 pages: Page1.asp & Page2.asp
I want visitors to be able to download Page2.asp when they click on a button on Page1.asp
An ordinary 'a href' won't do the trick because Page2 will be displayed in the browser window. The idea is that a save as dialog box appears... I have been searching for a solution all afternoon. Maybe some javascript could help?
I made it a simple example. In reality this is part of a file management page where users should be able to download all sort of files they uploaded before...
For now I'm using the following code:
If a visitor clicks on the 'download file' button the following page will be loaded in a new window:
<%
Set oFs = CreateObject("Scripting.FileSystemObject"
Set oFile = oFs.GetFile(server.mappath(request.querystring("url"
))
'request.querystring("url"
contains the file that should be uploaded to the visitor (eg. files/somefile.asp)
Response.ContentType = "application/x-msdownload"
Response.AddHeader "Content-Disposition", "attachment; filename=""" & oFile.Name & """"
If (Right(request.querystring("url"
,3) <> "asp"
And (Right(request.querystring("url"
,3) <> "asa"
Then
Server.Execute request.querystring("url"
Else
Set oFileStream = oFile.OpenAsTextStream
response.write oFileStream.ReadAll
Set oFileStream = NOTHING
End If
Set oFile = NOTHING
Set oFs = NOTHING
%>
All help would be greatfully appreciated.
Thanks
Tomas
I have the following problem.
I have 2 pages: Page1.asp & Page2.asp
I want visitors to be able to download Page2.asp when they click on a button on Page1.asp
An ordinary 'a href' won't do the trick because Page2 will be displayed in the browser window. The idea is that a save as dialog box appears... I have been searching for a solution all afternoon. Maybe some javascript could help?
I made it a simple example. In reality this is part of a file management page where users should be able to download all sort of files they uploaded before...
For now I'm using the following code:
If a visitor clicks on the 'download file' button the following page will be loaded in a new window:
<%
Set oFs = CreateObject("Scripting.FileSystemObject"
Set oFile = oFs.GetFile(server.mappath(request.querystring("url"
'request.querystring("url"
Response.ContentType = "application/x-msdownload"
Response.AddHeader "Content-Disposition", "attachment; filename=""" & oFile.Name & """"
If (Right(request.querystring("url"
Server.Execute request.querystring("url"
Else
Set oFileStream = oFile.OpenAsTextStream
response.write oFileStream.ReadAll
Set oFileStream = NOTHING
End If
Set oFile = NOTHING
Set oFs = NOTHING
%>
All help would be greatfully appreciated.
Thanks
Tomas