# Filereference, progressbar

**URL:** <https://forum.kirupa.com/t/filereference-progressbar/208544>\
**Category:** flash\
**Created:** [November 29, 2006, 9:48pm UTC](https://forum.kirupa.com/t/filereference-progressbar/208544 "2006-11-29T21:48:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![onetwo](https://avatars.discourse-cdn.com/v4/letter/o/3d9bf3/32.png) [@onetwo](https://forum.kirupa.com/u/onetwo)\
**Post date:** [November 29, 2006, 9:48pm UTC](https://forum.kirupa.com/t/filereference-progressbar/208544/1 "2006-11-29T21:48:03Z")

</div>

I have a script that works fine re uploading the multiple files I am selecting but I cannot get the progress bar to work.  
I could of course use the script often shown where files are uploaded as soon as they have been selected but I prefer to have the file names listed in a list and then user is to press upload button.  
When user press browse button the function brow () is activated. The name of the upload button is upload1.  
I assume there is plenty room for optimisiing the code. Please feel free to comment. Thanks for any comments.

import flash.net.FileReferenceList;  
import flash.net.FileReference;

upload1.onRelease = function(fileRefList:FileReferenceList)  
{  
this.enabled = false;  
var list:Array = fileRefList.fileList;  
for (var i:Number = 0; i\<list.length; i++)  
{  
trace("UPLOADING FILE: "+list\*.name);  
\_root.Application.produkter.annonce.upload\_pics.uploadFilesList.addItem({label: list\*.name})  
list\*.addListener(fileUploadsingle);  
list\*.upload(“[http://www.mydomain.com/upload.php](http://www.mydomain.com/upload.php)”);

}  
};

function brow(){

var fileUploadmulti:Object = new Object();  
var fileUploadsingle:Object = new Object();  
fileUploadmulti.onSelect = function(fileRefList:FileReferenceList)  
{  
var list:Array = fileRefList.fileList;  
for (var i:Number = 0; i\<list.length; i++)  
{  
trace("UPLOADING FILE: "+list\*.name);  
\_root.Application.produkter.annonce.upload\_pics.uploadFilesList.addItem({label: list\*.name})  
//list\*.addListener(fileUploadsingle);  
list\*.upload(“[http://www.mydomain.com/upload.php](http://www.mydomain.com/upload.php)”);  
}  
};  
fileUploadmulti.onCancel = function():Void  
{  
trace(“onCancel”);  
};  
fileUploadmulti.onOpen = function(file:FileReference):Void  
{  
trace("onOpen: “+file.name);  
};  
fileUploadsingle.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void  
{  
trace(file.name+” onProgress with bytesLoaded: “+bytesLoaded+” bytesTotal: "+bytesTotal);  
};  
fileUploadsingle.onComplete = function(file:FileReference):Void  
{  
trace("onComplete: "+file.name);  
};  
fileUploadsingle.onHTTPError = function(file:FileReference, httpError:Number):Void  
{  
trace("onHTTPError: “+file.name+” httpError: "+httpError);  
};  
fileUploadsingle.onIOError = function(file:FileReference):Void  
{  
trace("onIOError: "+file.name);  
};  
fileUploadsingle.onSecurityError = function(file:FileReference, errorString:String):Void  
{  
trace("onSecurityError: “+file.name+” errorString: "+errorString);  
};  
var allTypes:Array = new Array();  
var imageTypes:Object = new Object();  
imageTypes.description = “Images (\*.jpg, \*.jpeg, \*.gif, _.png)";  
imageTypes.extension = "_.jpg; \*.jpeg; \*.gif; \*.png”;  
allTypes.push(imageTypes);  
var fileRefList:FileReferenceList = new FileReferenceList();  
fileRefList.addListener(fileUploadmulti);  
fileRefList.browse(allTypes);  
}
