Link to home
Start Free TrialLog in
Avatar of jmccar68
jmccar68

asked on

Flash upload progress bar problem

I have problem with my flash upload progress bar. It works perfectly on localhost. But when i upload it on server, the progress bar doesn't work correctly. Please help me.
Here is my demo:
http://grhwood.com
import flash.net.FileReference;
 
 
var reference:FileReference = new FileReference();
var listener:Object = new Object();
 
//server script
var scriptLocation:String = 'uploader.php';
 
var progressBarHeight:Number = 10;
var progressBarY:Number = 50;
var progressBarColor:Number = 0x66ccff;
 
uploadButton_mc._visible = false;
 
chooseButton_mc.onRelease = choose;
uploadButton_mc.onRelease = uploadCurrent; //upload file
 
function choose():Void {
	reference.browse([{description:'All Files (*.*)', extension:'*.*'}]);
}
function uploadCurrent():Void {
	chooseButton_mc._visible = false;
	progressBar = makeProgressBar(0, progressBarY);
	reference.upload(scriptLocation);
}
 
listener.onSelect = function(file:FileReference):Void {
	display_txt.text = file.name;
	uploadButton_mc._visible = true;
}
 
listener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void {
	
	percent = Math.ceil(bytesLoaded*100/bytesTotal);
    display_txt.text = file.name+' - '+ percent +'%';
	progressBar._width = Math.ceil(Stage.width*(bytesLoaded/bytesTotal));
	percent_txt.text = bytesLoaded + "/" + bytesTotal;
}
 
listener.onComplete = function(file:FileReference):Void {
    removeMovieClip(progressBar);
	display_txt.text = '';
	uploadButton_mc._visible = false;
	chooseButton_mc._visible = true;
}
 
//attach Listener to the FileReference Object
reference.addListener(listener);
 
 
/***********************************************************/
function makeProgressBar(x:Number, y:Number):MovieClip {
	var bar:MovieClip = createEmptyMovieClip('progressBar_mc', 0);
	bar._visible = false;
	bar.beginFill(progressBarColor);
	bar.lineTo(Stage.width, 0);
	bar.lineTo(Stage.width, progressBarHeight);
	bar.lineTo(0, progressBarHeight);
	bar.lineTo(0, 0);
	bar.endFill();
	bar._width = 0;
	bar._visible = true;
	bar._x = x;
	bar._y = y;
	return bar;
}
/*************/

Open in new window

Avatar of Sci-Fi-Si
Sci-Fi-Si
Flag of United Kingdom of Great Britain and Northern Ireland image

Just uploaded a couple of test files (so you might to delete them) but the process worked fine, file size was correct and completed at 100%

Avatar of jmccar68
jmccar68

ASKER

I'm using Firefox 3.0 and when i upload a file, the progress bar goes to 100% even my file isn't uploaded.
Please help me!
ASKER CERTIFIED SOLUTION
Avatar of Sci-Fi-Si
Sci-Fi-Si
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you Sci-Fi-Si,

I tried uploading with another computer, and it works correctly. Only when i upload using my pc, the problem occurs.
I attach my screen shot below. And here is my source
http://grhwood.com/upload_file.rar
untitled.JPG
Glad I could help

All the best
Sci-Fi Si