Jump to content

Flash File Uploader


bcoffin

Recommended Posts

I'm using the file.upload feature of AS3 to show upload progress and it seems i'm creating a server side process that just grows and grows in memory demand. Uploading a 110MB file draws close to 720MB of memory at the time that i canceled the upload. Any suggestions?

 

I've removed LOADS of peripheral functionality from this to simplify.

But this is the meat+potatoes of the actionscript that's doing the upload (and spiking server memory):

_root.onEnterFrame = function() {
if (this.getBytesLoaded()/this.getBytesTotal()>0.99) {
	_root.onEnterFrame = function() {
		//trace ("onEnterFrame called");
	};
}
};

var m:MovieClip = this;
var a:Boolean = false;

import flash.net.FileReference;
var selected_file = undefined;
var filetype = undefined;

//used later in case typing fails*
var file_monitor = new Object();


setSelected = function (file) {
selected_file = file;
file_name.text = file.name;
};

file_monitor.onSelect = function(file) {

>>> buncha tests here removed
} else if (file.name) {
	setSelected(file);
} else {
	alert("Please select a file to upload.");
}

};

file_monitor.onOpen = function(file) {
progress_bar.setStatus("Uploading...");
time_started = getTimer();
};
file_monitor.onProgress = function(file, bytesLoaded, bytesTotal) {
progress_bar.setProgress(bytesLoaded,bytesTotal,getTimer()-time_started);
};

var file = new flash.net.FileReference();
file.addListener(file_monitor);


upload_btn.onRelease = function() {
upload_file("upload.php?custom_flags=values");
};
upload_file = function (dst) {
	file.upload(dst);
};

 

thanks for any suggestions/theories

Link to comment
Share on other sites

Don't use Flash to check the progress. I recently made some file upload application similar to flickr's but avoided using Flash. I used Javascript to get the progress via uploadprogress_get_info().

 

Here's something with an explanation:

 

http://www.clipclip.org/yaoweizhen/clips/email/20556/pecl-uploadprogress-example-%C2%BB-harper-reed-tech-phones-yo-yoing-and-death-metal

 

By the way, are you setting up _root manually? This is AS3 right?

Link to comment
Share on other sites

  • 3 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.