2 Replies Latest reply on Sep 19, 2010 11:26 PM by YogeshM

    Select a folder for batch upload

    YogeshM Level 1



      Is it possible to select a folder using CF?


      I'm trying to implement a batch upload and processing module and I'd like the user to select a folder containing all the files that need to be uploaded, instead of either selecting each file one by one, or doing multiple upload.


      Even if it's multiple upload, the user still has to choose each file manually.


      The idea is to automate this process to the maximum to reduce human intervention to the strict minimum.


      After the user has selected his/her folder and clicked on the Submit button, the program needs to copy all the files from the user's source folder to a destination folder on the server and then make use of cfdirectory to list all the files and process each one. This is not a problem. I have tested the following with a hard-coded directory and it works great!


      <!--- List files in the selected directory --->

      <cfdirectory directory="#variables.selectedDirectory#" action="list" name="qDir">

      <!--- Loop directory --->
      <cfoutput query="variables.qList">

           <!--- Invoke method to process each file in the directory --->
           <cfinvoke method="processFileUpload" returnvariable="qDone">
                <cfinvokeargument name="selectedFile" value="#variables.qDir.name#">



      The above is working already.


      Now, to be able to automate the file copy process from the user's source folder to the destination folder on the server, I need to provide the user with a form where he/she can point to his/her source folder.


      How can we do this in CF?


      Thanks in advance.




        • 1. Re: Select a folder for batch upload
          ilssac Level 5

          YogeshM wrote:


          How can we do this in CF?


          For CF to be able to do it, you have to be able to do it from the server.  IF you can log in to the ColdFusion server, and from that server go to 'Network Locations" and browse to a clients computer.  Then ColdFusion can do this, using the same UNC path you used in Network Locations.  This might be possible on a local network which one might have at some company or other oranizations.


          But CF can NOT see what is on the client machine through HTTP.  First of all, ColdFusion is not even talking to the client, the web server (IIS or Apache) is what talks the client.  ColdFusion is talking to the web server.  Secondly the HTTP protocol is designed to prevent exactly this type of interaction for security reasons.  IF one could do what you want to do with HTTP, it would be trivially easy for evil programmers to make web sites that trick users to upload all types of sensetive information.


          There are some client technolgoies that MIGHT do what you want.  Flash, JavaScript, is what you would need to be looking for, but usually these don't all just pointing at an entire directory, again for security reasons.

          1 person found this helpful
          • 2. Re: Select a folder for batch upload
            YogeshM Level 1

            Thanks a lot ilssac!


            Very helpful reply indeed!


            I'll most probably resort to a multiple upload module, I've already had a look at the Flex File Uploader.


            Thanks again for everything!


            Best regards,