以下为引用的内容:

import com.newmediateam.fileIO.*;

import flash.events.*;

import flash.media.*;

import flash.net.*;

import mx.containers.*;

import mx.controls.*;

import mx.core.*;

import mx.events.*;

import mx.styles.*;

public var snd:SoundAsset;

public var documentTypes:FileFilter;

public var soundClass:Class;

public var multiFileUpload:MultiFileUpload;

public var uploadDestination:String = "upload.php";

public var sndChannel:SoundChannel;

public var filesToFilter:Array;

public function uploadsfinished(event:Event) : void

{

sndChannel = snd.play();

return;

}// end function

public function initApp() : void

{

var _loc_1:* = new URLVariables();

_loc_1.path=this.parameters["file"];

multiFileUpload = new MultiFileUpload(filesDG, browseBTN, clearButton, delButton, upload_btn, progressbar, uploadDestination, _loc_1, 1024000000, filesToFilter);

multiFileUpload.addEventListener(Event.COMPLETE, uploadsfinished);

return;

}// end function

]]>

大家可以看到_loc_1.path=this.parameters["file"]接收file参数,然后传入MultiFileUpload对象中,这个的意思是你可以通过页面来定义上传的目录.对于MultiFileUpload组件的源码如下:

///

//

//    Multi-File Upload Component Ver 1.1

//

//  Copyright (C) 2006 Ryan Favro and New Media Team Inc.

//  This program is free software; you can redistribute it and/or

//  modify it under the terms of the GNU General Public License

//  as published by the Free Software Foundation; either version 2

//    of the License, or (at your option) any later version.

//

//    This program is distributed in the hope that it will be useful,

//    but WITHOUT ANY WARRANTY; without even the implied warranty of

//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

//    GNU General Public License for more details.

//

//    You should have received a copy of the GNU General Public License

//    along with this program; if not, write to the Free Software

//    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

//

//    Any questions about this component can be directed to it's author Ryan Favro at ryanfavro@hotmail.com

//

//  To use this component create a new instance of this component and give it ten parameters

//

//    EXAMPLE:

//

//    multiFileUpload = new MultiFileUpload(

//          filesDG,           //

//          browseBTN,         //

//          clearButton,         //

//          delButton,         // < -- Button component to be the button that removes a single selected file from the cue

//          upload_btn,         //

//          progressbar,         //

//          "http://[Your Server Here]/MultiFileUpload/upload.cfm", //

//          postVariables,      // < -- URLVariables type that will contain addition variables to accompany the upload

//          350000,             //< -- Number type to set the max file size for uploaded files in bytes. A value of 0 (zero) = no file limit

//          filesToFilter     // < -- Array containing FileFilters an empty Array will allow all file types

//           );

//

//

//

//    Enjoy!

//

///

package com.newmediateam.fileIO {

// Imported Class Definitions

import mx.controls.DataGrid;

import mx.controls.Button;

import mx.controls.ProgressBar;

import mx.controls.ProgressBarMode;

import mx.controls.dataGridClasses.*;

import mx.controls.Alert;

import mx.events.CollectionEvent;

import mx.collections.ArrayCollection;

import flash.events.*;

import flash.net.FileReferenceList;

import flash.net.FileFilter;

import flash.net.FileReference;

import flash.net.URLRequest;

import flash.net.URLVariables;

public class MultiFileUpload {

//UI Vars

private var _datagrid:DataGrid;

private var _browsebutton:Button;

private var _remselbutton:Button;

private var _remallbutton:Button;

private var _uploadbutton:Button;

private var _progressbar:ProgressBar;

private var _testButton:Button;

//DataGrid Columns

private var _nameColumn:DataGridColumn;

private var _typeColumn:DataGridColumn;

private var _sizeColumn:DataGridColumn;

private var _creationDate:DataGridColumn;

private var _modificationDate:DataGridColumn;

private var _progressColumn:DataGridColumn;

private var _columns:Array;

//File Reference Vars

[Bindable]

private var _files:ArrayCollection;

private var _fileref:FileReferenceList

private var _file:FileReference;

private var _uploadURL:URLRequest;

private var  _totalbytes:Number;

//File Filter vars

private var _filefilter:Array;

//config vars

private var _url:String; // location of the file upload handler can be a relative path or FQDM

private var _maxFileSize:Number; //bytes

private var _variables:URLVariables; //variables to passed along to the file upload handler on the server.

//Constructor

public function MultiFileUpload(

dataGrid:DataGrid,

browseButton:Button,

removeAllButton:Button,

removeSelectedButton:Button,

uploadButton:Button,

progressBar:ProgressBar,

url:String,

variables:URLVariables,

maxFileSize:Number,

filter:Array

){

_datagrid = dataGrid;

_browsebutton = browseButton;

_remallbutton = removeAllButton;

_remselbutton = removeSelectedButton;

_uploadbutton = uploadButton;

_url = url;

_progressbar = progressBar;

_variables = variables;

_maxFileSize = maxFileSize;

_filefilter = filter;

init();

}

//Initialize  Component

private function init():void{

// Setup File Array Collection and FileReference

_files = new ArrayCollection();

_fileref = new FileReferenceList;

_file = new FileReference;

// Set Up Total Byes Var

_totalbytes = 0;

// Add Event Listeners to UI

_browsebutton.addEventListener(MouseEvent.CLICK, browseFiles);

_uploadbutton.addEventListener(MouseEvent.CLICK,uploadFiles);

_remallbutton.addEventListener(MouseEvent.CLICK,clearFileCue);

_remselbutton.addEventListener(MouseEvent.CLICK,removeSelectedFileFromCue);

_fileref.addEventListener(Event.SELECT, selectHandler);

_files.addEventListener(CollectionEvent.COLLECTION_CHANGE,popDataGrid);

// Set Up Progress Bar UI

_progressbar.mode = "manual";

_progressbar.label = "";

// Set Up UI Buttons;

_uploadbutton.enabled = false;

_remselbutton.enabled = false;

_remallbutton.enabled = false;

// Set Up DataGrid UI

_nameColumn = new DataGridColumn;

_typeColumn = new DataGridColumn;

_sizeColumn = new DataGridColumn;

_nameColumn.dataField = "name";

_nameColumn.headerText= "File";

_typeColumn.dataField = "type";

_typeColumn.headerText = "File Type";

_typeColumn.width = 80;

_sizeColumn.dataField = "size";

_sizeColumn.headerText = "File Size";

_sizeColumn.labelFunction = bytesToKilobytes as Function;

_sizeColumn.width = 150;

_columns = new Array(_nameColumn,_typeColumn,_sizeColumn);

_datagrid.columns = _columns

_datagrid.sortableColumns = false;

_datagrid.dataProvider = _files;

_datagrid.dragEnabled = true;

_datagrid.dragMoveEnabled = true;

_datagrid.dropEnabled = true;

// Set Up URLRequest

_uploadURL = new URLRequest;

_uploadURL.url = _url;

_uploadURL.method = "GET";  // this can also be set to "POST" depending on your needs

_uploadURL.data = _variables;

_uploadURL.contentType = "multipart/form-data";

}

/********************************************************

*   PRIVATE METHODS                                     *

********************************************************/

//Browse for files

private function browseFiles(event:Event):void{

_fileref.browse(_filefilter);

}

//Upload File Cue

private function uploadFiles(event:Event):void{

if (_files.length > 0){

_file = FileReference(_files.getItemAt(0));

_file.addEventListener(Event.OPEN, openHandler);

_file.addEventListener(ProgressEvent.PROGRESS, progressHandler);

_file.addEventListener(Event.COMPLETE, completeHandler);

_file.addEventListener(SecurityErrorEvent.SECURITY_ERROR,securityErrorHandler);

_file.addEventListener(HTTPStatusEvent.HTTP_STATUS,httpStatusHandler);

_file.addEventListener(IOErrorEvent.IO_ERROR,ioErrorHandler);

_file.upload(_uploadURL);

setupCancelButton(true);

}

}

//Remove Selected File From Cue

private function removeSelectedFileFromCue(event:Event):void{

if (_datagrid.selectedIndex >= 0){

_files.removeItemAt( _datagrid.selectedIndex);

}

}

//Remove all files from the upload cue;

private function clearFileCue(event:Event):void{

_files.removeAll();

}

// Cancel Current File Upload

private function cancelFileIO(event:Event):void{

_file.cancel();

setupCancelButton(false);

checkCue();

}

//label function for the datagird File Size Column

private function bytesToKilobytes(data:Object,blank:Object):String {

var kilobytes:String;

kilobytes = String(Math.round(data.size/ 1024)) + ' kb';

return kilobytes

}

// Feed the progress bar a meaningful label

private function getByteCount():void{

var i:int;

_totalbytes = 0;

for(i=0;i < _files.length;i++){

_totalbytes +=  _files[i].size;

}

_progressbar.label = "Total Files: "+  _files.length+ " Total Size: " + Math.round(_totalbytes/1024) + " kb"

}

// Checks the files do not exceed maxFileSize | if _maxFileSize == 0 No File Limit Set

private function checkFileSize(filesize:Number):Boolean{

var r:Boolean = false;

//if  filesize greater then _maxFileSize

if (filesize > _maxFileSize){

r = false;

trace("false");

}else if (filesize <= _maxFileSize){

r = true;

trace("true");

}

if (_maxFileSize == 0){

r = true;

}

return r;

}

// restores progress bar back to normal

private function resetProgressBar():void{

_progressbar.label = "";

_progressbar.maximum = 0;

_progressbar.minimum = 0;

}

// reset form item elements

private function resetForm():void{

_uploadbutton.enabled = false;

_uploadbutton.addEventListener(MouseEvent.CLICK,uploadFiles);

_uploadbutton.label = "Upload";

_progressbar.maximum = 0;

_totalbytes = 0;

_progressbar.label = "";

_remselbutton.enabled = false;

_remallbutton.enabled = false;

_browsebutton.enabled = true;

}

// whenever the _files arraycollection changes this function is called to make sure the datagrid data jives

private function popDataGrid(event:CollectionEvent):void{

getByteCount();

checkCue();

}

// enable or disable upload and remove controls based on files in the cue;

private function checkCue():void{

if (_files.length > 0){

_uploadbutton.enabled = true;

_remselbutton.enabled = true;

_remallbutton.enabled = true;

}else{

resetProgressBar();

_uploadbutton.enabled = false;

}

}

// toggle upload button label and function to trigger file uploading or upload cancelling

private function setupCancelButton(x:Boolean):void{

if (x == true){

_uploadbutton.label = "Cancel";

_browsebutton.enabled = false;

_remselbutton.enabled = false;

_remallbutton.enabled = false;

_uploadbutton.addEventListener(MouseEvent.CLICK,cancelFileIO);

}else if (x == false){

_uploadbutton.removeEventListener(MouseEvent.CLICK,cancelFileIO);

resetForm();

}

}

/*********************************************************

*  File IO Event Handlers                                *

*********************************************************/

//  called after user selected files form the browse dialouge box.

private function selectHandler(event:Event):void {

var i:int;

var msg:String ="";

var dl:Array = [];

for (i=0;i < event.currentTarget.fileList.length; i ++){

if (checkFileSize(event.currentTarget.fileList[i].size)){

_files.addItem(event.currentTarget.fileList[i]);

trace("under size " + event.currentTarget.fileList[i].size);

}  else {

dl.push(event.currentTarget.fileList[i]);

trace(event.currentTarget.fileList[i].name + " too large");

}

}

if (dl.length > 0){

for (i=0;i

msg += String(dl[i].name + " is too large. \n");

}

mx.controls.Alert.show(msg + "Max File Size is: " + Math.round(_maxFileSize / 1024) + " kb","File Too Large",4,null).clipContent;

}

}

// called after the file is opened before upload

private function openHandler(event:Event):void{

trace('openHandler triggered');

_files;

}

// called during the file upload of each file being uploaded | we use this to feed the progress bar its data

private function progressHandler(event:ProgressEvent):void {

_progressbar.setProgress(event.bytesLoaded,event.bytesTotal);

_progressbar.label = "Uploading " + Math.round(event.bytesLoaded / 1024) + " kb of " + Math.round(event.bytesTotal / 1024) + " kb " + (_files.length - 1) + " files remaining";

}

// called after a file has been successully uploaded | we use this as well to check if there are any files left to upload and how to handle it

private function completeHandler(event:Event):void{

//trace('completeHanderl triggered');

_files.removeItemAt(0);

if (_files.length > 0){

_totalbytes = 0;

uploadFiles(null);

}else{

setupCancelButton(false);

_progressbar.label = "Uploads Complete";

var uploadCompleted:Event = new Event(Event.COMPLETE);

dispatchEvent(uploadCompleted);

}

}

// only called if there is an  error detected by flash player browsing or uploading a file

private function ioErrorHandler(event:IOErrorEvent):void{

//trace('And IO Error has occured:' +  event);

mx.controls.Alert.show(String(event),"ioError",0);

}

// only called if a security error detected by flash player such as a sandbox violation

private function securityErrorHandler(event:SecurityErrorEvent):void{

//trace("securityErrorHandler: " + event);

mx.controls.Alert.show(String(event),"Security Error",0);

}

//  This function its not required

private function cancelHandler(event:Event):void{

// cancel button has been clicked;

trace('cancelled');

}

//  after a file upload is complete or attemted the server will return an http status code, code 200 means all is good anything else is bad.

private function httpStatusHandler(event:HTTPStatusEvent):void {

//        trace("httpStatusHandler: " + event);

if (event.status != 200){

mx.controls.Alert.show(String(event),"Error",0);

}

}

}

}

flex file 文件上传 带参数 php,php+flex打造多文件带进度超级上传相关推荐

  1. 带参数的线性方程组怎么用计算机解,带参数的线性方程组的解法.docx

    带参数的线性方程组的解法.docx 带参数的线性方程组的解 法 左连 翠 济南大学 侯淑 轩 基础 部 摘要 对带参数的 线性方程组的解法进行了系统的研 讨 , 分类给出了具体的解 法 , 并对一类复 ...

  2. html文件可以带参数,一个带参数的URL指向一个静态文件后面的参数有没有作用?_html/css_WEB-ITnose...

    http://127.0.0.1/index.html?param1=asdfasdf&param2=asdfasdfa 请问?param1=asdfasdf&param2=asdfa ...

  3. url没有参数名怎么直接带参数_用30行Python爬虫带你看PLMM(划掉,喵星人)

    偶尔写写爬虫也算是打磨无聊生活的一种方式了. 之前写了一个用100多行Python爬虫看世界的帖子,有兴趣的朋友可以看一下. 带你用100多行Python爬虫看看今天的世界(上) 带你用100多行Py ...

  4. 【Qt教程】1.7 - Qt5带参数的信号、信号重载、带参数的槽函数、槽函数重载

    原理:与C++语法一致,信号.槽函数都可以发生重载,使其在名称不变的情况下,传递过程可以携带参数. 示例说明:我们从一个最普通的信号槽工程中,来修改,对信号.槽进行重载,使信号.槽携带参数. 1. 普 ...

  5. python带参数的装饰器的作用_Python带参数的装饰器运行原理解析

    关于装饰器的理解,特别像<盗梦空间>中的进入梦境和从梦境出来的过程,一层一层的深入梦境,然后又一层一层的返回,被带入梦境的是被装饰的函数,装饰器就是使人入梦的工具. 上代码: from f ...

  6. laravel生成微信公众号带参数二维码并响应扫描带参数二维码

    微信公众号后台ip白名单.网页接口域名之类的配置就不多说了,这里主要配置的是开发->基本配置->服务器配置(注:一旦启用改配置,公众号自动回复就会失效): 1.服务器地址(URL):这里要 ...

  7. shll脚本带参数输入给导出的数据库文件命名以及创造路径

    做个笔记 代码 #!/bin/bashBASE_DIR=$(cd "$(dirname "$0")/../../results";pwd) export cur ...

  8. java重定向带参数_急 求助重新封装重定向带参数问题

    该楼层疑似违规已被系统折叠 隐藏此楼查看此楼 这是我写的代码 不知道行不行 求助 package base.web.resolver.result;import java.util.HashMap;i ...

  9. python 文件写入多个参数_pandas 把数据写入txt文件每行固定写入一定数量的值方法...

    我遇到的情况是:把数据按一定的时间段提出.比如提出每天6:00-8:00的每个数据,可以这样做: # -*-coding: utf-8 -*- import pandas as pd import d ...

最新文章

  1. 数据结构实验——中缀表达式转为后缀表达式
  2. Python使用matplotlib绘制透明背景的可视化图像并保存透明背景的可视化结果(transparent background)
  3. Bug改到怀疑人生…… | 每日趣闻
  4. VS2005右键点击转到定义后出现“未定义符号”的提示及其解决
  5. c/c++函数指针(Hook前奏1)
  6. python怎么读取word文件_python之python-docx编辑和读取word文档
  7. Mysql常用命令(二)
  8. https无法访问 宝塔_宝塔面板快速开启ssl(https)的方法
  9. java io 缓存读取_Java 文件IO写入读取四种方法
  10. python控制ppt定时_python中使用requests实现自动回帖.ppt
  11. jQuery导入Eclipse后报错解决方法
  12. 最短路径算法之四——SPFA算法
  13. qt 读取mysql数据库_qt 读取mysql数据库
  14. 用JCreator编写java程序
  15. 微信小程序开发页面跳转教程
  16. win10透明任务栏教程
  17. 计算机视觉之混合图像(Hybrid)
  18. JCA - 核心类和接口
  19. 联想笔记本的3.5mm耳机孔 没有声音!!!
  20. kubelet源码 删除pod pod_workers.go(三)

热门文章

  1. 安装插件设置Intellij IDEA背景图片
  2. bzoj1041 [HAOI2008]圆上的整点 gcd
  3. 2017.10.29 软件安装 思考记录
  4. 2017.3.22 小z的袜子 思考记录
  5. mariadb 和mysql主从_Mariadb/Mysql 主从复制(1)
  6. unity添加对象实例_在Unity中,如何通过值复制一个GameObject,以便在实例化之前修改它?...
  7. 查看、修改linux系统的最大链接数限制、文件描述符限制、端口范围限制、虚拟内存等
  8. Java:输出“水仙花数”
  9. ABB机器人VGT文件_ABB机器人与焊机之间通讯方式
  10. 辽宁省计算机辅助普通话水平测试应试指南,计算机辅助普通话水平测试 应 试 指 南...