Below is my code for uploading multiple files.But I am able to upload only
single file at a  time.I am not able to understand why this is
happening.Please help me.

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"; width="400"
height="300" creationComplete="myFunction();">
<mx:Button x="10" y="10" label="Choose Files" id="btnSelectFiles"/>
<mx:Button x="114" y="10" label="Upload" id="btnUpload" visible="false"/>
<mx:Label x="10" y="208" width="100%" id="lblFileName" fontWeight="bold"/>
<mx:List borderStyle="none" backgroundAlpha="0" x="10" y="40" width="30%"
id="listSelectedFiles" visible="false" />
<mx:Label x="10" y="234" width="100%" id="lblUploadedBytes"
fontWeight="bold"/>
<mx:Label x="10" y="260"  width="100%" id="lblTotalBytes"
fontWeight="bold"/>
<mx:Script>
    <![CDATA[
        import mx.messaging.AbstractConsumer;
        public var fileReferenceList:FileReferenceList = new
FileReferenceList();
        public function eventResponse(Event:MouseEvent):void
        {
            // Set the file filters in the open dialog box
            var typeFiler:FileFilter = new FileFilter("All","*.*");
            //var typeFiler:FileFilter = new FileFilter("Images (*.jpg,
*.jpeg, *.gif, *.png)", "*.jpg; *.jpeg; *.gif; *.png");
           fileReferenceList.browse([typeFiler]);
        }
        public function selectResponse(event:Event):void
        {
            // Create an array with the size of the selected files.
            var filesSelected:Array = new
Array(fileReferenceList.fileList.length);
            // Loop through all the selected files and add their names to
the List control
            for(var i:int=0;i<fileReferenceList.fileList.length;i++)
            {
                var fileReference:FileReference =
fileReferenceList.fileList[ i ];
                filesSelected[ i ] = fileReference.name;
            }
            listSelectedFiles.dataProvider = filesSelected;
            listSelectedFiles.visible = true;
            btnUpload.visible = true;
        }
        public function myFunction(): void
        {
           btnSelectFiles.addEventListener(MouseEvent.CLICK, eventResponse);
           btnUpload.addEventListener(MouseEvent.CLICK, btnUploadResponse);
           fileReferenceList.addEventListener(Event.SELECT,selectResponse);
        }
        public function UploadFiles():void
        {
            // If the user selected 1 or multiple files
            if(fileReferenceList.fileList.length > 0)
            {
                // For each file selected
                for(var i:int=0;i<fileReferenceList.fileList.length;i++)
                {
                    // Create a FileReference instance of each file
                    var fileReference:FileReference =
fileReferenceList.fileList[ i ];
                    // Create a new URLRequest class: The parameter is the
aspx handler page
                    var request:URLRequest = new URLRequest("
http://localhost:2347/UploadFile.aspx";);
                    fileReference.addEventListener(ProgressEvent.PROGRESS,
progressStatus);
                   request.contentType = "application/octet-stream";
                   request.method = "POST";
                   fileReference.upload(request,fileReference.name,false);
                }
            }
        }
        public function btnUploadResponse(event:Event):void
        {
            // Disable the Select files button, upload button, and call the
UploadFiles function
            btnSelectFiles.enabled = false;
            btnUpload.enabled = false;
            UploadFiles();
        }
        public function progressStatus(event:ProgressEvent):void
        {
            var file:FileReference = FileReference(event.target);
            // Set the name of the currently being uploaded file
            lblFileName.text = "Uploading File: " + file.name;
            // Set the number of bytes being uploaded
            lblUploadedBytes.text = "Bytes Uploaded: " + event.bytesLoaded;
            // Set the total number of bytes
            lblTotalBytes.text = "Total Size: " + event.bytesTotal + "
bytes";
        }
    ]]>
</mx:Script>



</mx:Canvas>


*.Net Code*
*
*
*
protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                for (int i = 0; i < Request.Files.Count; i++)
                {
                    string fileName =
System.IO.Path.GetFileName(Request.Files[i].FileName);

 Request.Files[i].SaveAs(Server.MapPath("~/UploadedFile/ProductImages/") +
fileName);
                }
            }
            catch (Exception ex)
            {
                string s = ex.Message.ToString();
            }
        }
*


Thanks & regards
  Vishal

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Flex 
India Community" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/flex_india?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to