5 file uploads = 5 requests?

I am playing around with multiple image uploads. I’m using this code from adobe:


			fileRefList.addEventListener(Event.SELECT, selectHandler);
			fileRefList.browse();

			function selectHandler(event:Event):void{
				var request:URLRequest = new URLRequest("testUpload.php");
				var file:FileReference;
				var files:FileReferenceList = FileReferenceList(event.target);

				var selectedFileArray:Array = files.fileList;
				for (var i:uint = 0; i < selectedFileArray.length; i++){
					file = FileReference(selectedFileArray*);
					file.addEventListener(Event.COMPLETE, completeHandler);
					try
					{
						file.upload(request);
					}
					catch (error:Error)
					{
						trace("Unable to upload files.");
					}
				}
			}
			function completeHandler(event:Event):void
			{
				trace("uploaded");
			}


Whats weird is that it is calling the testUpload.php script 5 times. It also seems like it upload every file concurrently - which doesn’t seem to make sense. It could also be that flash player queues the uploads internally, and I’m just over thinking it.

My questions:

  • How can I do a progress bar if it is 5 separate actions with 5 separate events.
  • Is there a way I can send multiple files in one request?