views:

256

answers:

2

cfhttp with a get to download the files. Does anyone have an example of cfhttp working? Are there special settings that need to be set up on the server side to get this tag to work. When I try the following code:

<CFHTTP
    METHOD = "get"
    URL="http://data.bls.gov/PDQ/servlet/SurveyOutputServlet?series_id=LNU04032231&amp;years_option=specific_years&amp;to_year=2010&amp;from_year=2009&amp;delimiter=comma&amp;output_view&amp;output_format=excelTable"
    path="/Users/Deepak" 
    file="testfile.xls">

Nothing comes back to my computer? How do you get it to pop up the "where do you want to save the file box" dialogue box?

I am submitting a form in coldfusion by hitting this link http://data.bls.gov/PDQ/servlet/SurveyOutputServlet?series_id=LNU04032231&amp;years_option=specific_years&amp;to_year=2010&amp;from_year=2009&amp;delimiter=comma&amp;output_view&amp;output_format=excelTable I am getting a excel file as a result. How can I save this file on my local box. Or, is it possible to directly read the content of file without saving it in my local box through coldfusion using cfftp or cfhttp?

cfhttp.mimeType is application/vnd.ms-excel in this case. Thanks!!

+1  A: 

I'm not certain I understand the question, but let me try anyway:

Using cfhttp, you can submit the form variables to the URL, and get back the data. From there, you could save it, manipulate it in memory, or whatever.

If you need to push the content to the client from CF, you can use cfheader and cfcontent to do so.

If this does not answer what you are asking, please clarify the question.

Ben Doom
Deepak Yadav
Are you attempting to open this file on the server, so that CF can manipulate it, or push the file to the client (browser)?
Ben Doom
A: 

Run it by hand once to see if it is really an excel file or an HMTL file with an "xls" extension, which is a common trick. If it is HTML, then it is gonna be a pain to read.

If it is Binary, then use CFHTTP with the "file" and "path" attributes to download the file to your server. Then you can use cfspreadsheet (CF9) to read the excel binary.

If you don't have CF9 then check out POI which is what CF9 is using to implement the cfspreadsheet tag

Mark Porter
yes its really an excel file. And cfhttp.fileContent is null. Because after hitting the above url we get an excel file to save or open.
Deepak Yadav
Even when I save the file from a browser it has 0 bytes.
Leigh
Hey thanks Leigh.. actually that excel file was empty. That was a bit wrong url. I am sorry for wasting all of yours time.
Deepak Yadav
Well, glad you found the problem.
Leigh