当前位置:首页 > Web开发 > 正文

求超大文件上传方案( B/S )

2024-03-31 Web开发

需求:项目要撑持大文件上传成果,颠末讨论,初阶将文件上传巨细控制在500M内,因此本身需要在项目中进行文件上传部分的调解和配置,本身将巨细都以501M来进行限制。

第一步:

前端改削

由于项目使用的是BJUI前端框架,并没有使用框架自己的文件上传控件,而使用的基于jQuery的Uploadify文件上传组件,在项目使用的jslib项目中找到了BJUI框架集成jQuery Uploadify的部分,这部分代码封装在bjui-all.js文件中,

在bjui-all.js文件中的全局变量界说中有以下部分代码,这就是界说的有关于上传的Uploadify控件的重要变量:

//文件上传东西

function FileUploader(fileLoc, mgr)

{

    var _this = this;

    this.id = fileLoc.id;

    this.ui = { msg: null, process: null, percent: null, btn: { del: null, cancel: null,post:null,stop:null }, div: null};

    this.isFolder = false//不是文件夹

    this.app = mgr.app;

    this.Manager = mgr; //上传打点器指针

    this.event = mgr.event;

    this.Config = mgr.Config;

    this.fields = jQuery.extend({}, mgr.Config.Fields, fileLoc.fields);//每一个东西自带一个fields幅本

    this.State = this.Config.state.None;

    this.uid = this.fields.uid;

    this.fileSvr = {

          pid: ""

        , id: ""

        , pidRoot: ""

        , f_fdTask: false

        , f_fdChild: false

        , uid: 0

        , nameLoc: ""

        , nameSvr: ""

        , pathLoc: ""

        , pathSvr: ""

        , pathRel: ""

        , md5: ""

        , lenLoc: "0"

        , sizeLoc: ""

        , FilePos: "0"

        , lenSvr: "0"

        , perSvr: "0%"

        , complete: false

        , deleted: false

    };//json obj,处事器文件信息

    this.fileSvr = jQuery.extend(this.fileSvr, fileLoc);

    //筹备

    this.Ready = function ()

    {

        this.ui.msg.text("正在上传行列队伍中期待...");

        this.State = this.Config.state.Ready;

        this.ui.btn.post.click(function () {

            _this.ui.btn.post.hide();

            _this.ui.btn.del.hide();

            _this.ui.btn.cancel.hide();

            _this.ui.btn.stop.show();

            if (!_this.Manager.IsPostQueueFull()) {

                _this.post();

            }

            else {

温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/web/31678.html