先来看看效果图吧:
下面就是在as iframe里面加的代码.
import flash.net.FileReference;
import mx.controls.Alert;
var my_pb:mx.controls.ProgressBar;
var maxSize = 1000*1000*100; //文件大小限制:100M
//设置进度栏模式
my_pb.mode = "manual";
my_pb.label = "上传进度:%1%";
my_pb._visible=false
//进度栏增加前的最小数值
my_pb.minimum = 0;
// 进度栏停止前的最大值
my_pb.maximum = 100;
var increment_num:Number = my_pb.minimum;
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 textTypes:Object = new Object();
//textTypes.description = "Text Files (*.txt, *.rtf)";
//textTypes.extension = "*.txt;*.rtf";
//allTypes.push(textTypes);
var flvType:Object =new Object();
flvType.description ="flv Files (*.flv)";
flvType.extension ="*.flv";
allTypes.push(flvType);
var rmType:Object =new Object();
rmType.description ="rm Files (*.rm)";
rmType.extension ="*.rm";
allTypes.push(rmType);
// 定义警告确认后的动作。
var myClickHandler:Function = function (evt_obj:Object) {
if (evt_obj.detail == Alert.OK) {
trace("start stock app");
}
};
var listener:Object = new Object();
listener.onSelect = function(file:FileReference):Void {
trace("onSelect: " + file.name);
filesurl.text=file.name;
msg( "对不起您选择的文件太大!");
//if(!file.upload("http://localhost/upfiles/hlp.php")) {
// trace("Upload dialog failed to open.");
//}
if (file.size<=maxSize)
{
//strState.text = "您选择得文件:" + file.name + "n";
btnUpload.enabled = true;
}else
{
msg( "对不起您选择的文件太大!");
btnUpload.enabled = false;
}
}
listener.onCancel = function(file:FileReference):Void {
trace("onCancel");
}
listener.onOpen = function(file:FileReference):Void {
trace("onOpen: " + file.name);
}
listener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void {
trace("onProgress with bytesLoaded: " + bytesLoaded + " bytesTotal: " + bytesTotal);
my_pb.setProgress ((bytesLoaded / bytesTotal) * 100, my_pb.maximum);
}
listener.onComplete = function(file:FileReference):Void {
trace("111111111111onComplete: " + file.name);
//msg("上传完毕!");
getURL ("Javascript: formsub ()");
}
listener.onHTTPError = function(file:FileReference):Void {
trace("onHTTPError: " + file.name);
msg("onHTTPError: " + file.name);
}
listener.onIOError = function(file:FileReference):Void {
trace("onIOError: " + file.name);
msg("onIOError: " + file.name);
}
listener.onSecurityError = function(file:FileReference, errorString:String):Void {
trace("onSecurityError: " + file.name + " errorString: " + errorString);
msg("onSecurityError: " + file.name + " errorString: " + errorString);
}
var fileRef:FileReference = new FileReference();
fileRef.addListener(listener);
this.btnBrowse.onRelease = function () {
fileRef.browse(allTypes);
};
//this.btnUpload.onRelease = function () {
// if(!fileRef.upload("/upload.php")) {
//trace("Upload dialog failed to open.");
//}
// 显示警告对话框。
//}
//fileUploadURL="/upload.php";
function scrubba() {
if(fileUploadURL){
my_pb._visible=!false;
btnBrowse.enabled = false;
if(!fileRef.upload(fileUploadURL)) {
trace("Upload dialog failed to open.");
}
fileUploadURL='';
}
}
_root.onEnterFrame = scrubba;
function msg(msgtxt:String) {
Alert.show(msgtxt, "消息", Alert.OK , this, myClickHandler, "stockIcon", Alert.OK);
}
说明:hlp.php文件是php文件上传代码,详细请到本站去找.
我最强舞者 (I, Best Dancer)安卓版v8
我最强舞者(I, Best Dancer)是一款休闲放置类手
迷你世界国服版本2024 v1.43.0
迷你世界国服版本2024是一款自由度非常高的沙盒游戏,玩法和
烹饪乐园 安卓版v1.23.6
烹饪乐园(Cooking Town)是一款非常好玩的餐厅模拟
迷你世界小米服 最新安卓版v1.43.0
迷你世界小米版是由迷你玩科技开发的休闲模拟经营类游戏。此版本
布娃娃Sprunki沙盒 安卓版v0.0.1
布娃娃Sprunki沙盒是一个非常有趣的沙盒游戏,复古简约的