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

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

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

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


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

footer  footer  footer  footer