all groups > flash actionscript > august 2005 >
You're in the

flash actionscript

group:

FILE UPLOAD


FILE UPLOAD atlacatl
8/11/2005 10:02:40 PM
flash actionscript:
:confused; Does anyone know how the new file upload on flash 8 works? any white
papers/help topics anywhere? can someone tell me or point me to the official
explanation or something close. Thanks, I'm sure many of us are wondering the
same thing.
Re: FILE UPLOAD CR_COOL
8/25/2005 12:00:00 AM
Re: FILE UPLOAD atlacatl
9/10/2005 12:22:41 AM
Re: FILE UPLOAD atlacatl
9/10/2005 12:28:13 AM
G, Yahoo search had my answer..........thanks allot flashers.....
Re: FILE UPLOAD Roks-1
9/10/2005 12:30:11 AM
Here is a web link that has the sample code you are looking for:
http://www.franto.com/blog2/maelstrom-uploadingdownloading-examples

Here is the code they used for Upload:

fileUpload = new Object ();
fileUpload.onSelect = function (f) {
// We want only *.as files on Server, and not the really big ones ;-)
if (f.type == ".as" && f.size <= 15000) {
err.text = "";
for (var i in f) {
err.text += i + ": " + f + '\r';
}
file.text = f.name;
upload.enabled = true;
} else {
upload.enabled = false;
file.text = '';
err.text = "Select an '*.as' File.";
}
};
/**
* Gets called when the user cancels / closes BrowseForFile Dialog
**/
fileUpload.onCancel = function () {
upload.enabled = false;
err.text = "No file selected! You should select a file ;-)";
};
/**
* Gets called when the .upload() function is called on a file
**/
fileUpload.onOpen = function (fileRef, err, response) {
err.text += "Upload started " + '\r';
err.text += arguments;
};
fileUpload.onProgress = function (file, bytesLoaded:Number, bytesTotal:Number)
{
var percent = Math.round (bytesLoaded / bytesTotal * 100);
progressBar.setProgress(percent, 100);
err.text += "\ronProgress: " + file.name + " (" + percent + "%)";
};
fileUpload.onHTTPError = function (file, errorCode:Number) {
err.text += "\ronHTTPError: " + file.name + " HTTP Error Code: " +
errorCode;
};
/**
* If upload is called on a non http url like file://
* but only if you don't read the boolean result from upload() for some reason.
* makes some sense actually, var result = file.upload("file://"); returns
false;
* but file.upload("file://"); throws callback error onIOError.
**/
fileUpload.onIOError = function (file) {
err.text += "\nonIOError: " + file.name + " could not be uploaded (try
uploading to jsp/asp/php scripts on a webserver)";
};
//
// More than one file to upload
// fileRef = new flash.net.FileReferenceList ();
fileRef = new flash.net.FileReference ();
fileRef.addListener (fileUpload);
onBrowse = function () {
// ask the user to choose a file to upload
fileRef.browse ();
};
browse.addEventListener ('click', onBrowse);
onUpload = function () {
fileRef.upload ("?");
};
upload.enabled = false; // the upload-button is disabled as long as there's no
need for it / we've not selected a file.
upload.addEventListener ('click', onUpload);
AddThis Social Bookmark Button