Date:  02/14/2003 02:24:41 AM Msg ID:  001329
From:  James Williams Thread:  001319
Subject:  Re: Showing a word document in the browser
in my actual script i pass in a attachment id do a lookup in the attachments table get the file name and then show the document, i have
changed this to passing in the filename into the script with no database lookup. It now seems to work. Do not know why.
 
thanks for the quick response. i am enjoying using your foxweb product.
 
Sent by FoxWeb Support on 02/13/2003 11:11:41 AM:
It works fine for me even if I try to open the file in another window.  Here's the code I used:
 
<%
IF request.querystring("logout") = "1"
 Auth.Logout()
 %>
 <html>
 <head><title>Word Test</title></head>
 <body>
 You have successfully logged out.<br>
    <a href="testword.fwx">Try again</a>
    </body></html>
 <%
 Response.End
ENDIF
Auth.AuthTable = "data\Users.dbf"
Auth.AuthFormFile = "authform.fwx"
Auth.Header = ""
Auth.Footer = ""
Auth.SaveCookie = 1
Auth.Authenticate()
 
M.FileName = Request.QueryString("FileName")
IF EMPTY(M.FileName)
 %>
 <html>
 <head><title>Word Test</title></head>
 <body>
    <a href="#" onclick="window.open('testword.fwx?FileName=test.doc','Wordwindow','left=0,
    top=0,width=800,height=700,scrollbars,menubar')">Click to view word file</a><br>
    <a href="#" onclick="window.open('testword.fwx?FileName=mountains.jpg','Wordwindow',
    'left=0,top=0,width=800,height=700,scrollbars,menubar')">Click to view image file</a><br>
    <br>
    <a href="testword.fwx?logout=1">Logout</a>
    </body></html>
 <%
ELSE
 DO CASE
 CASE LOWER(JUSTEXT(M.FileName)) = "doc"
  M.ContentType = "application/msword"
 CASE INLIST(LOWER(JUSTEXT(M.FileName)), "jpg", "jpeg")
  M.ContentType = "image/jpeg"
 OTHERWISE
  Response.Write("File type not supported")
  Response.End
 ENDCASE
 IF FILE(M.FileName)
  Response.AddHeader("Content-Disposition", "inline; filename=" + M.FileName)
  FileContent = ReadFile(M.FileName)
  * Specify size so that progress bar works properly
  Response.AddHeader("Content-Length", Server.ToString(LEN(M.FileContent)))
  Response.ContentType = M.ContentType
  * Send file to browser
  Response.Write(M.FileContent)
 ELSE
  Response.Write("File not found")
 ENDIF
ENDIF
%>

FoxWeb Support Team
support@foxweb.com email

Sent by James Williams on 02/13/2003 03:38:31 AM:

Your code and my code will run fine in its on window (being called directly)

Did you run my code or your code from a new popup window. using (window.open)

I now know my code did not generate the word or image file not was not necessary to show you the problem.

The page if set to display a word doc generates the auth form as a word document.

also email notification not working.

Sent by FoxWeb Support on 02/12/2003 07:05:09 PM:
Your code does not seem to add the content of the word file to the output, but once we added this it all worked fine.  Here's the code we used:
 
<%
Auth.AuthTable = "data\Users.dbf"
Auth.AuthFormFile = "authform.fwx"
Auth.Header = ""
Auth.Footer = ""
Auth.SaveCookie = 1
Auth.Authenticate()
 
M.FileName = "test.doc"
M.ContentType = "application/msword"
Response.AddHeader("Content-Disposition", "inline; filename=" + M.FileName)
FileContent = ReadFile(M.FileName)
* Specify size so that progress bar works properly
Response.AddHeader("Content-Length", Server.ToString(LEN(M.FileContent)))
Response.ContentType = M.ContentType
* Send file to browser
Response.Write(M.FileContent)
%>
 

FoxWeb Support Team
support@foxweb.com email

Sent by James Williams on 02/12/2003 06:26:33 AM:
I am having trouble using the auth object in conjuntion with a file download (but only if the file type is that of a word document).
 
If the auth object is not used the word doc download works fine.
 
Here is a sample of the problem
 
File saved as "testword.fwx"
 
<%
Auth.AuthTable = "data\Users.dbf"
Auth.AuthFormFile = "authform.fwx"
Auth.Header = ""
Auth.Footer = ""
Auth.SaveCookie = 1
Auth.Authenticate()
 
cShowType = Request.QueryString("ShowType")
If Empty(cShowType)
     Response.Write("<html><head><title>Word Test</title></head><body><br>")
     Response.Write('<a href="javascript:window.open('+"'testword.fwx?ShowType=1','Wordwindow','left=0,top=0,width=800,height=700,scrollbars,menubar'"+')">Click to view word file</a>')
     Response.Write("<br>")
     Response.Write('<a href="javascript:window.open('+"'testword.fwx?ShowType=2','Wordwindow','left=0,top=0,width=800,height=700,scrollbars,menubar'"+')">Click to view image file</a>')
     Response.write("<br></body></html>")
Else
     If cShowType = "1"
          Response.ContentType = "application/msword"
     Else
          Response.ContentType = "image/jpeg"
     Endif
Endif
Response.End
%>