Devenfadia
Programmer
Hi,
I am using response.redirect to redirect, which works fine on one of our servers but doesn't work on another server. I tried lots of solutions but nothing helped. Second Problem is open file which is opening a file or let user save the file on his/her desktop works fine on one server but another server it is trying to open a file in browser. and if the file is PDF document then it shows some garbage.
I will really appreciate your help.
By the way it's on windows 2000 server with IIS 5.0.
Here is the code:
<%
Dim filename, fileID, method, test, strDoc, temp, tempurl
filename = request.querystring("filename"
fileID = request.querystring("fileID"
strDoc = filename
Dim rsHistory, ls_sql, MySql
Set rsHistory = Server.CreateObject("ADODB.Recordset"
ls_sql = "select * from CA_History "
If Request.Form("R1" = "Email" then
Response.redirect(buildurl("SendAttachments.asp"&"&fileid=" & cstr(fileID))
else
if Request.Form("R1" = "Open" then
method = "Open"
Dim Stream
Dim Contents
Dim FileExt
Const adTypeBinary = 1
If filename = "" Then
Response.Write "Filename not specified."
Response.End
End If
' Make sure they are not requesting your
' code
FileExt = Mid(filename, InStrRev(filename, "." + 1)
Select Case UCase(FileExt)
Case "ASP", "ASA", "ASPX", "ASAX", "MDB"
Response.Write "Protected file not allowed."
Response.End
End Select
' Download the file
Response.Clear
Response.ContentType = "application/octet-stream"
Response.AddHeader "content-disposition", "attachment; filename=" & FileName
Set Stream = server.CreateObject("ADODB.Stream"
Stream.Type = adTypeBinary
Stream.Open
Stream.LoadFromFile Server.MapPath("\Email Data\CorrectiveAction\" & FileName)
While Not Stream.EOS
Response.BinaryWrite Stream.Read(1024 * 64)
Wend
Stream.Close
' response.redirect("History.go(-1)"
Set Stream = Nothing
Response.Flush
else
Set File = CreateObject("Scripting.FileSystemObject"
ImagePath = "Inetpub\"
ImagePath = ImagePath & filename
MySql = "Delete from FileAttachments where FileID = " & fileID
If File.fileExists(ImagePath) Then
Session("db_con".Execute(MySql)
File.DeleteFile(ImagePath)
%>
<html>
<head>
<title>Action</title>
</head>
<body>
<table border="0" cellpadding="2" cellspacing="1" width="100%">
<tr>
<td width="100%" bgcolor="#993366"><font color="#FFFFFF" face="Arial" size="2"><b>Delete
Confirmation</b></font></td>
</tr>
<tr>
<td width="100%" bgcolor="#C0C0C0" valign="top">
<form name="form1" method="POST" action="<%=session("urladdr"%> ">
<input type="hidden" name="link" value>
<input type="hidden" name="linktab" value>
<input type="hidden" value name="ChangesFlag">
<table border="0" cellpadding="2" cellspacing="1" width="100%">
<tr>
<td width="100%" align="center">
<p align="left"> File has been deleted.
</td>
</tr>
<tr>
<td width="100%" align="center"><input type="button" value="Back" name="Back" onClick="func9()">
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<%
Else
response.write("File doesn't exists."
End if
End if
end if
%>
</body>
</html>
I am using response.redirect to redirect, which works fine on one of our servers but doesn't work on another server. I tried lots of solutions but nothing helped. Second Problem is open file which is opening a file or let user save the file on his/her desktop works fine on one server but another server it is trying to open a file in browser. and if the file is PDF document then it shows some garbage.
I will really appreciate your help.
By the way it's on windows 2000 server with IIS 5.0.
Here is the code:
<%
Dim filename, fileID, method, test, strDoc, temp, tempurl
filename = request.querystring("filename"
fileID = request.querystring("fileID"
strDoc = filename
Dim rsHistory, ls_sql, MySql
Set rsHistory = Server.CreateObject("ADODB.Recordset"
ls_sql = "select * from CA_History "
If Request.Form("R1" = "Email" then
Response.redirect(buildurl("SendAttachments.asp"&"&fileid=" & cstr(fileID))
else
if Request.Form("R1" = "Open" then
method = "Open"
Dim Stream
Dim Contents
Dim FileExt
Const adTypeBinary = 1
If filename = "" Then
Response.Write "Filename not specified."
Response.End
End If
' Make sure they are not requesting your
' code
FileExt = Mid(filename, InStrRev(filename, "." + 1)
Select Case UCase(FileExt)
Case "ASP", "ASA", "ASPX", "ASAX", "MDB"
Response.Write "Protected file not allowed."
Response.End
End Select
' Download the file
Response.Clear
Response.ContentType = "application/octet-stream"
Response.AddHeader "content-disposition", "attachment; filename=" & FileName
Set Stream = server.CreateObject("ADODB.Stream"
Stream.Type = adTypeBinary
Stream.Open
Stream.LoadFromFile Server.MapPath("\Email Data\CorrectiveAction\" & FileName)
While Not Stream.EOS
Response.BinaryWrite Stream.Read(1024 * 64)
Wend
Stream.Close
' response.redirect("History.go(-1)"
Set Stream = Nothing
Response.Flush
else
Set File = CreateObject("Scripting.FileSystemObject"
ImagePath = "Inetpub\"
ImagePath = ImagePath & filename
MySql = "Delete from FileAttachments where FileID = " & fileID
If File.fileExists(ImagePath) Then
Session("db_con".Execute(MySql)
File.DeleteFile(ImagePath)
%>
<html>
<head>
<title>Action</title>
</head>
<body>
<table border="0" cellpadding="2" cellspacing="1" width="100%">
<tr>
<td width="100%" bgcolor="#993366"><font color="#FFFFFF" face="Arial" size="2"><b>Delete
Confirmation</b></font></td>
</tr>
<tr>
<td width="100%" bgcolor="#C0C0C0" valign="top">
<form name="form1" method="POST" action="<%=session("urladdr"%> ">
<input type="hidden" name="link" value>
<input type="hidden" name="linktab" value>
<input type="hidden" value name="ChangesFlag">
<table border="0" cellpadding="2" cellspacing="1" width="100%">
<tr>
<td width="100%" align="center">
<p align="left"> File has been deleted.
</td>
</tr>
<tr>
<td width="100%" align="center"><input type="button" value="Back" name="Back" onClick="func9()">
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<%
Else
response.write("File doesn't exists."
End if
End if
end if
%>
</body>
</html>