4 Replies Latest reply on Mar 23, 2010 8:36 AM by GeorgeWS

    downloading files

    GeorgeWS Level 1

      I have a datagrid that displays files that are on my webserver. You can press on the file and download it to the server. Most of my DG that have files work great. The ones that do not are the ones that are trying to diplay only one file. It shows a blank. But if I put a second file in the folder on the server the 2 files show. Has anyone run across this issue?



        • 1. Re: downloading files
          Madhav Subedi Level 4

          can you post the code to depict the overall scenario?

          • 2. Re: downloading files
            GeorgeWS Level 1

            Pretty much this is what I am doing. The is an initApp on complete, and the file paths are not real. There is a flashvar SupplierID that changes the folder. Works great except when there is only one file in the folder on the server. When there are 2 or more files it all works perfectly.






            import mx.collections.ArrayCollection;


            import mx.rpc.events.ResultEvent;


            import mx.controls.Alert;


            // Start of Download





            Bindable] public var directoryDS:ArrayCollection;




            Bindable] public var serviceURL:String;




            Bindable] public var fileIndex:Number;





            public function initApp():void




            function initApp():




            serviceURL =



            "http://www.youngsmarket.com/myprograms/reviews.cfm?SupplierID="+parentDocument.SupplierID; //Set the URL to the httpservice

            directoryDS =


            new ArrayCollection([]); // This is where the results of the httpservice will end up.

            fileIndex = -1;



            // Call the httpservice.






            // Taking the data returned from the httpservice and creating FileDownload objects to populate the directoryDS array collection.



            private function setDataSource(evtObj:Object):void




            var fileDL:DownloadFile;


            var collection:ArrayCollection = evtObj.directory.file as ArrayCollection; // pass httpservice result into a local scope



            var i:int;



            //loop over results and create a new DownloadFile object and add it to the directoryDS ArrayCollection



            for (i=0;i < collection.length; i++)


            fileDL =

            new DownloadFile();

            fileDL._file = collection.getItemAt(i).name;

            fileDL._url =

            "http://www.youngsmarket.com/myfiles/"+parentDocument.SupplierID+"/"; // Change this to match your Files directory path.

            fileDL._size = collection.getItemAt(i).size;










            // Fire the downloadFile method of the DownloadFile ojbect selected from the Datagrid.



            private function downloadFile():void




            // first make sure there is a selection



            if (fileIndex >= 0)











            // labed function for the datagrid size column



            private function toKiloBytes(item:Object,obj:Object):String{



            var size:Number = item._size / 1024;



            if (size >= 1){


            return Math.round(size) + " kb";




            return size * 1024 + " b";










            id="directory_srv" url="{serviceURL}" result="setDataSource(event.result)"/>




            dataProvider="{directoryDS}" id="filesDG" change="setFileIndex(event.target.selectedIndex);"


            98%" height="98%" themeColor="#73B9B9" doubleClickEnabled="true" itemDoubleClick="downloadFile()">




            <mx:DataGridColumn dataField="_file" headerText="File" minWidth="150" />


            <mx:DataGridColumn dataField="_size" headerText="Size" minWidth="100" />








            MY CFM  is like this...


            <cfset directoryPath="//web/myfiles\#SupplierID#\">
            <cfdirectory action="list"  directory="#directoryPath#"  name="qDirectory">

            <?xml version="1.0" encoding="utf-8"?>
            <cfoutput query="qDirectory">
            <file name="#qDirectory.name#" type="#qDirectory.type#" size="#qDirectory.size#"/>




            Thanks for looking



            • 3. Re: downloading files
              GeorgeWS Level 1

              I still have not found a solution. When displaying files that are on a server in a DG

              if there is only one file in the folder nothing shows in the DG. If there are more than one file it works perfectly.

              Anyone else have this issue?





              • 4. Re: downloading files
                GeorgeWS Level 1

                Still no solution for this problem.