Misty:

If I correctly understand what you are trying to do, the attached HTML file
may contain relevant information. It's just a thread from an Allaire forum
that I saved locally to read.

Keith Purtell, Web/Network Administrator
VantageMed Operations (Kansas City)
Email:  [EMAIL PROTECTED]

CONFIDENTIALITY NOTICE: This email message, including any attachments, is
for the sole use of the intended recipient(s) and may contain confidential
and privileged information. Any unauthorized review, use, disclosure or
distribution is prohibited. If you are not the intended recipient, please
contact the sender by reply email and destroy all copies of the original
message.


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
Behalf Of Misty Woodward
Sent: Thursday, February 21, 2002 2:36 PM
To: [EMAIL PROTECTED]
Subject: RE: [KCFusion] CFContent Issues


ya I have about 3 different options I can offer them that would make things
a whole lot easier. But the look of the way this works has to replicate what
they currently have in Server Side Javascript (which I hav begun to hate
after this project). So I can do anything cool with Excel 2000, link
directly to the file or anything else that would make my life easier.

Misty

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
Behalf Of Darin Spence
Sent: Thursday, February 21, 2002 2:27 PM
To: [EMAIL PROTECTED]
Subject: RE: [KCFusion] CFContent Issues


If the client is using Excel 2000, you might consider creating an Excel
file for them that uses the "Web Query" feature.  We've started doing
this as opposed to creating Excel files "on-the-fly."  Create a "raw
data" page (simple table with the data in it) then from Excel use a Web
Query and point to that page.  What's cool is in Excel you can just have
a sheet called "Raw Data," then other sheets that build graphs based on
the data on the fly.  When they want to update their graphs, they just
refresh the web query.

Good luck!
-Darin

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On
Behalf Of Misty Woodward
Sent: Thursday, February 21, 2002 1:19 PM
To: [EMAIL PROTECTED]
Subject: [KCFusion] CFContent Issues


Hi all.  Hopefully someone here has ran into this problem...

I have an excel exporter type deal. Now before I get alternative
suggestions for how I can do this let me explain how it has to "look" to
the client.

I am on a page that shows a table format of query results. There is a
little Excel Icon that I click on to export my results to an XLS file
(not csv). A small window about 2 inches wide, 1 inch across pops up and
says "Building Excel File....Please wait"  so I CFFLUSH that much to the
page while it builds the file and writes it to the server using CFFILE.

Once that file is completely written I then display "Retrieving Data".
This is where I then through Javascript submit the page to another file
called getfile.cfm.  In getfile.cfm I am using CFCONTENT to retrieve
that file back out of the server and then delete it.

The problem is two things...

1. When I get the pop up box it says I am trying to download a file
"getfile.cfm" Why is it naming the file in the pop up box the name of my
CFM template?  But when I click save as it saves it with the correct
name "myfile.xls". Someone on the macromedia board suggested I put the
filename after the getfile.cfm page as you can see in the code below,
and it seems to fix this problem, but I dont know how stable this is.

2. When I click open instead of save as, it doesnt open. Instead, I get
a second dialog box asking me once again if I want to open or save as.
This time, if I choose open, it does open Excel and I can read the file.
Why would it give me this pop up twice?

After the file downloads I close the window that originally popped up.
Which also isn't working, but I think that is because CF isn't letting
me process the page anymore after I use CFCONTENT or submit to a new
page. Here is the code I am using...

gen_excel.cfm

<!--- Lots of code up here parsing out the excel sheet and query  blah
blah blah --->

<font id=medium><b> 2. Retrieving Data</b></font>
<form action="getfile.cfm/<cfoutput>#filename#</cfoutput>.xls"
method="post" name="TheForm">
        <input type="hidden" name="filename"
value="<cfoutput>#filename#</cfoutput>.xls">
</form>
<script language="JavaScript">
document.TheForm.submit();
</script>



getfile.cfm
<cfsetting enablecfoutputonly="yes">
<cfparam name="filename" default="download.xls">
<CFHEADER NAME="Content-Type" VALUE="application/unknown"> <CFHEADER
NAME="Content-Disposition" VALUE="attachment; filename=""#Filename#""">
<CFCONTENT TYPE="application/unknown" FILE="#path_to_tempdir##filename#"
deletefile="yes">
<cfsetting enablecfoutputonly="no">

Any help would be greatly appreciated.  The poeple at Macromedia and the
boards and such either don't know or just aren't helpful.

Thanks,
Misty Woodward
BigOSoftware
[EMAIL PROTECTED]
www.BigOSoftware.com
Contact us about our Developer Discount Program
6709 W 119th Street
Suite 422
Overland Park, KS 66209
913-219-2210

Title: ColdFusion Support Forums - Download any file type using CFCONTENT! Please...


OldForumUser  


Posts: 0
Joined: Mar 2001

Wednesday, June 14, 2000 12:30 PM


How can I set up the CFCONTENT tag to download any given file type???. I've put the CFCONTENT into a file of it's own. I also pass the full root address and file name to the CFCONTENT page.. Where I'm getting frustrated is the TYPE attribute in the CFCONTENT. If I put Text/doc, it will download Word files, but loads Excel files in the browser and tries to display GIF or JPEG files. Can anyone tell me if there is a generic or wild card term for the TYPE attribute?. I've tried:- ANY, ALL, Application/unknown, Application/exe, Application/x-unknown, etc.. I'm using Server 4.5.. Thanks,
Ryan

HTMLCODE


Author: Ogaard


Top
Bottom



OldForumUser  


Posts: 0
Joined: Mar 2001

Thursday, June 15, 2000 10:55 AM


CFCONTENT is one of those tags that really is frustrating. It seems sometimes like it is so close to a good thing,
then you spend a lot of time pulling out your hair.
The *hard* part of CFCONTENT seems to be getting the download file to have the correct extention. It _appears_
that you have figured this part out. The part that you are currently working on, I hate to say, is beyond your control. Having a browser open a file when it downloads is not a server-side setting, but rather a browser setting.
When you receive content through the web, there are two things that the browser tries to do. First, it checks the MIME type. This is the idea behind CFCONTENT. However, newer browsers (ESPECIALLY M$ variety) are annoying and use the file extention to identify files. When a file (such as a .DOC or .XLS file are downloaded, the browser checks to see what the associated programs are.
Case in point: when you finally download a file that has an unknown extension, there will be a box that will appear and ask you "what do you want to do with this file: open it in place, or download it. There often is another box that says something to the extent of "always perform this action". By default, many "common" file extentions these days get opened in browsers without your input. You can root around in your system settings and change this, if you go to tools/file options and then the extension of your choice.
Is there a way around it? Not without being terribly annoying. If you rename the file extesion from "this.jpg" to "this.jpg[1]" or something similar, the browser will almost *always* ask you to download it.

HTMLCODE


Author: barry croker


Top
Bottom



OldForumUser  


Posts: 0
Joined: Mar 2001

Thursday, June 15, 2000 11:32 AM



The correct mimetype for Microsoft Excel is application/vnd.ms-excel. This should solve your particular question. However, you may also want to know that there is a workaround KB article that fixes a problem where the correct file name is not assigned. See: http://www2.allaire.com/Handlers/index.cfm?ID=8629&Method=Full to learn how to do it.


I will attach my code for a simple three document test that works for me. In my example the files are located in the directory C:\Inetpub\wwwroot\test\xls\ To use my code, put all 3 files into this directory ***or change the path in the CFCONTENT FILE="path_here" attribute*** to point to the xls file you want to manipulate.


The workaround requires a page (i call it pre_content.cfm) before the one with the CFCONTENT tag (i call content.cfm). The pre_content.cfm template has an anchor that has the xls file name appended to the end, and this is passed to the content.cfm template when you click on it. (A HREF="content.cfm/mytest.xls") This ensures the correct file name when opening or saving the xls file. (Without the workaround the file wants to be saved as 'content.cfm' in my example).



Steven Erat
Allaire Technical Support
[EMAIL PROTECTED]
***Please make all replies/ inquiries through the forum***






HTMLCODE
precontent.cfm template:
========================
<html>
<head>
<title>Link to CFCONTENT Page with KB Workaround</title>
</head>

<body>

<A HREF=""content.cfm/mytest.xls">CFCONTENT
Example for XLS</A>

</body>
</html>

===============
content.cfm template:
===============
<HTML>
<HEAD>
<TITLE> CFCONTENT Example
</TITLE>
</HEAD>

<BODY>


<CFCONTENT TYPE="application/vnd.ms-excel" FILE="C:\Inetpub\wwwroot\test\xls\mytest.xls" DELETEFILE="No">

</BODY>
</HTML>

Author: Steven Erat


Top
Bottom



OldForumUser  


Posts: 0
Joined: Mar 2001

Thursday, June 15, 2000 2:47 PM


This problem gets asked many times. There have been several really good explanations posted in these forums - I suggest you search. Keywords for this post: MIME, cfheader, CFCONTENT, content-disposition. Netscape determines what to do with a file by its MIME-type (the correct way). IE determines what to do with a file by its extension (the wrong way). Thus you need to give a file an unrecognized extension AND an unrecognized MIME-type to make sure it downloads and no browser tries to display it. The solution suggested by the Allaire rep is not optimal. The latest version of IIS has a setting which will break his solution of appending the desired filename onto the path of the .cfm file. Below is a better way.

-- Michael Sims


HTMLCODE
Just do this:

<cfheader NAME="Content-Disposition" VALUE="attachment; filename=chicago1.txt">
<CFCONTENT TYPE="application/x-forced_download">

The MIME-type is a bogus one (pick anything bogus), and the cfheader
indicates the desired filename. "Attachment" indicates
it should be downloaded rather than displayed. Then you can link to it normally:

<A HREF=""download.cfm">
and when they follow that link, they'll get a "save this file"
prompt and the default filename will be (in this example)
"chicago1.txt". Thus you can download a text file and force it to be downloaded rather than displayed. In the above example I'm building the text file after the CFCONTENT tag, but you could also use CFCONTENT to just retrieve a file from the server and serve it out. Just make sure to lead with that cfheader.


Author: Michael Sims


Top
Bottom



OldForumUser  


Posts: 0
Joined: Mar 2001

Thursday, June 15, 2000 4:49 PM


Hello. Thank you all for your quick responses! I tried the code that Mike Sims suggested and it does force the browser to download the file. However,
CF doesn't recognize the underscore(_) character as well as others. So it doesn't save correctly. Also, IE still gives the user the option to open with the save. When you select open it tries to open in the browser. Which crashes the app. . I would prefer to have a "Save Only" dialogue box pop-up in both Netscape and IE and then save with the correct filename and type. . Any further help is greatly appreciated. Regards,
Ryan Ogaard.

HTMLCODE


Author: Ogaard


Top
Bottom



OldForumUser  


Posts: 0
Joined: Mar 2001

Thursday, June 15, 2000 5:01 PM


I've never experienced your issue with the underscore character. I just tried setting filenames with underscores, and it worked fine in both IE and Netscape. As far as I know, any character that would normally be a legal filesystem character should work fine. IE does give an option to open the file. I've never tried it, so I don't know about crashing the application. I don't believe you'll be able to get rid of that - that's IE's standard download dialog box, with "Save to disk" preselected but "Open" still available if the user chooses it, and I don't think there's any way to work around it.

-- Michael Sims


HTMLCODE


Author: Michael Sims


Top
Bottom



OldForumUser  


Posts: 0
Joined: Mar 2001

Thursday, June 15, 2000 5:14 PM



I've just tested the above method suggested by Michael Sims which does not recommend setting the MIME-type. My environment is NT4 SP5 IIS4 CFServer 4.5.1. Using that method I found that MSIE 5 does give a choice to Open the file or Save the file. This method does not employ the KB workaround, and the File Download box displays the template.cfm name (incorrect). When Save This File is selected, chicago1.txt (correct) appears in the Save As box. Selecting Open This File on the File Download box spawns a second File Download box with the redundant choice of Save this File or or Open This File, but correctly showing chicago1.txt this time.


Furthermore, I also tested this method with an xls document and a pdf document rather than the chicago1.txt file. In both cases, the file was saved with the correct name. However, upon opening the document in Excel I found an empty document rather than my previously populated Excel file, or in the case of the pdf document, Acrobat reported an error and would not open the downloaded file.


Using Netscape 4.7 with Michael's method avoided the redundant dialog boxes as found with MSIE 5, but spawned an ambiguous "You have started to download a file of type application/x-forced_download" box. When selecting Save File, the file was saved with the correct default name. However, upon opening the file I encountered empty documents or error messages depending on the file type that was being manipulated.


If I am in error and others can correct my logic then I would like to know how to get Michael's method to work properly. Otherwise, in my opinion, this is not an optimal method and appears to corrupt or not properly save the file as intended, and also requires redundant windows lending to confusion.


The method which I described in an earlier thread (involving pre_content.cfm, content.cfm) did not use the cfheader, but rather employed the workaround which appends the anchor on the previous page (A HREF="content.cfm/mytest.xls") and passes the name to download page where mytest.xls appears correctly in the dialog box. And upon opening the saved document, whether it is a pdf, xls, or txt MIME-type, the document opens without error and displays the correct body or data population. This requires that you specifically define the MIME-type in the CFCONTENT TYPE="" attribute.


I am not familiar with the problem described as "The latest version of IIS has a setting which will break his solution", and will have to research and test this. However, the only disadvantage I have found with the workaround setup is that to save the file in MSIE (rather than automatically open it) is to right click on the link and choose the Save function. Netscape offers a choice of Open or Save. I will have to stand by the method that I previously described as the optimal one.


KB workaround:
http://www2.allaire.com/Handlers/index.cfm?ID=8629&Method=Full



Steven Erat
Allaire Technical Support
[EMAIL PROTECTED]
***Please make all replies/ inquiries through the forum***



HTMLCODE


Author: Steven Erat


Top
Bottom



OldForumUser  


Posts: 0
Joined: Mar 2001

Thursday, June 15, 2000 5:34 PM


Steven. Thank you for stepping through Mike's post. I have written a web-based mail app. in CF and I would like to give a user the ability to click on an attachment and then save it to their computer, regardless of it's file type. How do I do this. Thanks,
Ryan Ogaard.

HTMLCODE


Author: Ogaard


Top
Bottom



OldForumUser  


Posts: 0
Joined: Mar 2001

Thursday, June 15, 2000 6:05 PM



I'll have to try out some possibilities. I think you'll still have to define the MIME type, but you can do it dynamically.

The first thing that comes to mind is to set up some variables where the downloaded file is CFSET varFullName = varFile & "." & varExt , and run a conditional logic statement that compares the varExt variable with possible file extensions (varMime), and appropriately completes the CFCONTENT TYPE="#varMime#" FILENAME="path/#varFullName#" attributes. The link would have to be A HREF="template.cfm/#varFullName#". Note that when setting attributes equal to variables you must enclose those tags within CFOUTPUT tags.

Please let me know if you'd like me to follow up with code. For the moment, remember that this is just my guess and I haven't tested this.



Steven Erat
Allaire Technical Support
[EMAIL PROTECTED]
***Please make all replies/ inquiries through the forum***



HTMLCODE


Author: Steven Erat


Top
Bottom



OldForumUser  


Posts: 0
Joined: Mar 2001

Thursday, June 15, 2000 6:06 PM



I'll have to try out some possibilities. I think you'll still have to define the MIME type, but you can do it dynamically.

The first thing that comes to mind is to set up some variables where the downloaded file is CFSET varFullName = varFile & "." & varExt , and run a conditional logic statement that compares the varExt variable with possible file extensions (varMime), and appropriately completes the CFCONTENT TYPE="#varMime#" FILENAME="path/#varFullName#" attributes. The link would have to be A HREF="template.cfm/#varFullName#".

Note that when setting attributes equal to variables you must enclose those tags within CFOUTPUT tags.

Please let me know if you'd like me to follow up with code. For the moment, remember that this is just my guess and I haven't tested this.



Steven Erat
Allaire Technical Support
[EMAIL PROTECTED]
***Please make all replies/ inquiries through the forum***



HTMLCODE


Author: Steven Erat


Top
Bottom



OldForumUser  


Posts: 0
Joined: Mar 2001

Thursday, June 15, 2000 6:14 PM


That would be great if you could post what the code may look like. I am calling a getfile.cfm that does the actual download. Thanks.

HTMLCODE


Author: Ogaard


Top
Bottom



OldForumUser  


Posts: 0
Joined: Mar 2001

Friday, June 16, 2000 1:24 PM


Steve,

The following message from the CF-Talk mailing list might point you in the right direction in understanding the problem described as "The latest version of IIS has a setting which will break this solution". There is a suggested work-around for this too suggested by Dave Watts (see below).

PS: I haven't tested it. (Still on SP 5).

-Ganesh

HTMLCODE
Date: Fri, 19 May 2000 16:47:06 -0400
From: [EMAIL PROTECTED] (Dave Watts)
To: <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Subject: RE: CFCONTENT and SP6A Message-ID: <002001bfc1d3$add34e70$[EMAIL PROTECTED]>

> I am trying to get the "/" to work again on a server with CF
> 45 Enterprise and NT SP6A.
>
> The issues has to do with winsock changes made in SP6. I
> know it is IIS's cause, but they have not released a hotfix
> for it.
>
> My code generates a file, we used to use the "/" to change
> the name of the file the user would get.
>
> <form action="/cranew/modules/generate-csv.cfm/#tempfile#"
> name="csv" method="post">
>
> That used to work, now we get
>
> "HTTP Error 405
> 405 Method Not Allowed
> The method specified in the Request Line is not allowed for
> the resource identified by the request.

You won't be able to "fix" this. It's not really a bug; that's how it should have worked all along; URLs should be parsed from right to left by the server, not from left to right.

In any case, you might be able to work around it anyway, by changing your form action to point to the correct URL and using cfheader in that action page, as shown in the first example here:

http://www.figleaf.com/demo/mimetest/

Alternately, if that doesn't work for you, you can add the csv extension to your server as a file that can be parsed by CF.

Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/
voice: (202) 797-5496
fax: (202) 797-5444

Author: Ganesh Ramaprakash


Top
Bottom



OldForumUser  


Posts: 0
Joined: Mar 2001

Monday, June 19, 2000 9:38 AM


Does anyone have a list of MIME type extensions. Thanks,
Ryan.

HTMLCODE


Author: Ogaard


Top
Bottom



OldForumUser  


Posts: 0
Joined: Mar 2001

Friday, August 18, 2000 2:10 PM


I've adappted the code presented by Michael Sims above to download Email attachments to the users computer. I run in an NT4.0, SP4, IIS4, CF Pro4.5 environment. I have tried it with a number of attachment file types, to include Word, Excell, PDF, and Text. I have tried it with both Explorer and Netscape. Both seem to work eaqually well. It also seems to make no difference if I save the file or open it at the browser prompt. Saved files are saved with the correct name, and opened files launch the appropriate application and load the file. Code is listed below

HTMLCODE
<cfpop action="GETALL"
name="message"
messagenumber="#messagenumber#"
attachmentpath="c:\temp\att\"
server="#pop_server#"
username="#pop_username#"
password="#pop_password#">

<cfheader name="Content-Disposition"
value="attachment; filename=#message.attachments#">

<CFCONTENT type="application/x-forced_download"
file="c:\temp\att\#message.attachments#"
deletefile="Yes">

Author: Jim Leeper


Top
Bottom



OldForumUser  


Posts: 0
Joined: Mar 2001

Friday, August 18, 2000 2:11 PM


I've adappted the code presented by Michael Sims above to download Email attachments to the users computer. I run in an NT4.0, SP4, IIS4, CF Pro4.5 environment. I have tried it with a number of attachment file types, to include Word, Excell, PDF, and Text. I have tried it with both Explorer and Netscape. Both seem to work eaqually well. It also seems to make no difference if I save the file or open it at the browser prompt. Saved files are saved with the correct name, and opened files launch the appropriate application and load the file. Code is listed below

HTMLCODE
<cfpop action="GETALL"
name="message"
messagenumber="#messagenumber#"
attachmentpath="c:\temp\att\"
server="#pop_server#"
username="#pop_username#"
password="#pop_password#">

<cfheader name="Content-Disposition"
value="attachment; filename=#message.attachments#">

<CFCONTENT type="application/x-forced_download"
file="c:\temp\att\#message.attachments#"
deletefile="Yes">

Author: Jim Leeper


Top
Bottom



OldForumUser  


Posts: 0
Joined: Mar 2001

Monday, October 30, 2000 9:20 AM


I've tried this solution.
it works well with IE5 and NN4 but doesn't work with IE4 !!!
do you have the same thing ?

Author: Rodolphe

 

©1995-2002 Macromedia, Inc. All rights reserved.

Reply via email to