HTML, CSS, JavaScript, Flash
Re: Problem with Vista
10/06/2008
05:38:05 PM
2HC11SRNK Show this entire thread in new window
From:
Reg Brehaut
To:
Rick Steinwand
Attachments:
None
Sorry, forgot one line:

Response.Write(lcFileBuffer)

RETURN .T.

Rick

Thanks Rick, I appreciate getting this; I will certainly make use of it to simplify the process I have now.

Thanks again

Reg
Here's my routine to send attachments:

LPARAMETERS tcFullPathToFile, tnContentType, tcString, tcFileDisplayName
LOCAL lcFileBuffer, lcContentType

IF NOT FILE(tcFullPathToFile) AND EMPTY(tcString)
RETURN .F.
ENDIF

IF EMPTY (tnContentType)
tnContentType = 4 && Text
ENDIF

IF EMPTY(tcFileDisplayName)
tcFileDisplayName = tcFullPathToFile
ENDIF

* eliminates printing junk to screen
DOEVENTS

IF EMPTY(tcString)
lcFileBuffer = FILETOSTR(tcFullPathToFile)
ELSE
lcFileBuffer = tcString
ENDIF

IF EMPTY(lcFileBuffer)
RETURN .F.
ENDIF

DO CASE
CASE tnContentType = 1
lcContentType = "application/octet-stream"
CASE tnContentType = 2
lcContentType = "application/x-zip-compressed"
CASE tnContentType = 3
lcContentType = "application/x-zip"
CASE tnContentType = 4
lcContentType = "text/plain"
CASE tnContentType = 5
lcContentType = "application/msword"
CASE tnContentType = 6
lcContentType = "application/vnd.ms-excel"
CASE tnContentType = 7
lcContentType = "application/ms-powerpoint"
CASE tnContentType = 8
lcContentType = "application/pdf"
CASE tnContentType = 9
lcContentType = "application/rtf"
OTHERWISE
lcContentType = "application/octet-stream"
ENDCASE

Response.ContentType = lcContentType
Response.AppendHeader("Content-Disposition", [attachment; filename=] + JUSTFNAME(tcFileDisplayName))
Response.GZipCompression = .T.
Response.Write(lcFileBuffer)


I usually use a .csv.txt extension and a type "text/plain" for CSV files.

Rick

Thanks for the reply and the info, Rick.

I thought it was going to be something like that. My work around, because it appears that the problem has a lot to do with whether IE thinks you specifically requested the download or not, is to put a link on the page where the report is created, rather than attempting to do a window.open(); when the operator clicks on the link, IE recognizes that you asked for it and behaves as we would expect and offers to Open, Save or Cancel. We just can't do it automatically any more.

Thanks again,

Reg

That's really an IE 7 issue - it blocks access to any files that open applications that potentially run script code (as all office apps do)...

I don't think there's a way to override this though - you can change the Mime type settings of the format though I believe. Find a file with the .csv extension and and right click on properties. There should be an option page somewhere that allows you to select what app opens it and whether there is prompting or not.

Note that it 'll also help if you provide an explicit Content Type type in your output of the file.

+++ Rick ---

More on this:

It is indeed a security issue. If I navigate to a webpage first and then refresh that page and redirect to the csv file, Vista puts up a bar at the top of the browser saying "download has been blocked, click here etc." and at least you get to click there and accept the download. But I could not find a setting in Internet Options Security settings to avoid this hassle.

What a pain!

Reg