Skip to main content
Participant
May 13, 2009
Question

cfdirectory

  • May 13, 2009
  • 1 reply
  • 1342 views

Below code is to download files from a directory. But problem is , OPEN/SAVE dialog box appears only for 1st file. Once that file is saved, it is not getting next file to download..

Can you help me?

<CFDIRECTORY NAME="myfiles"  DIRECTORY="C:\temp\" >

<cfoutput query="myfiles">
  <cfheader name="Content-Disposition" value="attachment; filename=#myfiles.Name#">
<cfcontent type="application/octet-stream" file="C:\temp\#myfiles.Name#">
</cfoutput>

This topic has been closed for replies.

1 reply

ilssac
Inspiring
May 13, 2009

Yeah, that is not going to work.  I'm not sure the HTTP protocol allows for multiple files like that.  I know I've never tried anything like that.  I just doesne't seem right for the nature of the sever client relationship.  ColdFusion is going to try and complete the entire loop before sending the response to the client.  The wierdest part is that it gives you the first file.  I would have expected only the last file.


The quickest alternative I can think of is have the output loop create a list of links that when clicked on by the user will go to a 'downloadFile.cfm' page that provides the header and content for the file specified in the link.

Another possiblity is to use zip technologies to combine all the files in the directory into a single zip file and download that.

Other then those, I have no idea how one would download multiple files like that through a web browser client.

maduraiAuthor
Participant
May 13, 2009

Oh no...please do not tell me that we cannot do mutiple downloads using CF...

ilssac
Inspiring
May 13, 2009

I'm not telling you that....

I'm telling you that you can't do multiple downloads with the HTTP webserver client-server protocol.

If you can show me how any web languagage allows you to stuff multiplie files into the header of a response to a browser, I can probably show you how to do it with ColdFusion.

But that is not my understanding of how web servers and web clients pass files around, but I may be wrong.  Since the browser can definatly send multiple files to a server.  I just know I have never ever downloaded multipe files from a web server using any technology.