打造PHP多文件带进度超级上传_PHP技巧_黑客防线网安服务器维护基地--Powered by WWW.RONGSEN.COM.CN

打造PHP多文件带进度超级上传

作者:黑客防线网安网站维护基地 来源:黑客防线网安网站维护基地 浏览次数:0

本篇关键词:PHPflex
黑客防线网安网讯:最近我们龙虎鹰师网安要做一个文件上传的功能,要求是可以批量上传,并且是大影音文件,于是在网上找了相关的资料和开源项目,进行了一些简单的改造。
最近我们黑客防线网安要做一个文件上传的功能要求是可以批量上传并且是大影音文件,于是在网上找了相关的资料和开源项目,进行了一些简单的改造

效果截图:

flex的源码是:

以下为引用的内容:

<?xml version="1.0" encoding="UTF-8"?>
<mx:Application creationComplete="{initApp();}" height="384" layout="vertical" xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:Script><![CDATA[
        import mx.events.*;
        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

    ]]></mx:Script>
    <mx:Panel height="330" layout="absolute" title="文件上传" width="652">
        <mx:DataGrid bottom="30" id="filesDG" left="0" right="0" top="5"/>
        <mx:ProgressBar bottom="5" height="20" id="progressbar" labelPlacement="center" left="0" right="0" trackHeight="15"/>
        <mx:ControlBar>
          
            <mx:Spacer width="100%"/>
            <mx:HBox>
                <mx:Button id="browseBTN" label="浏览文件"/>
                <mx:Button id="upload_btn" label="上传"/>
                <mx:Button id="delButton" label="删除"/>
                <mx:Button id="clearButton" label="全部清除"/>
            </mx:HBox>
        </mx:ControlBar>
    </mx:Panel>  
</mx:Application>

      大家可以看到_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,           // <-- DataGrid component to show the cue'd files

//          browseBTN,         // <-- Button componenent to be the browser button

//          clearButton,         // <-- Button component to be the button that removes all files from the cue

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

//          upload_btn,         // <-- Button component to be the  button that triggers the actual file upload action

//          progressbar,         // <-- ProgressBar Component that will show the file upload progress in bytes

//          "http://[Your Server Here]/MultiFileUpload/upload.cfm", // <-- String Type the url to the server side upload component can be a full domain or relative

//          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;
    黑客防线网安服务器维护方案本篇连接:http://www.rongsen.com.cn/show-6861-1.html
网站维护教程更新时间:2011-08-01 15:34:11  【打印此页】  【关闭
我要申请本站N点 | 黑客防线官网 |  
专业服务器维护及网站维护手工安全搭建环境,网站安全加固服务。黑客防线网安服务器维护基地招商进行中!QQ:29769479

footer  footer  footer  footer