thinkphp3.2 批量上传文件

js

if(window.FileReader) {

            var FileController = u.file.upload;                    // 接收上传文件的后台地址
            // FormData 对象
            var form = new FormData();

            form.append("author", "hooyes");                        // 可以增加表单数据
            form.append("beginTime", data.beginTime);

            for(var i = 0 , len=data.file.length; i <len;i++){
                var fileObj = document.getElementById("file").files[i]; // 获取文件对象
                form.append("file"+i, fileObj);                           // 文件对象
            }
            // XMLHttpRequest 对象
            var xhr = new XMLHttpRequest();
            xhr.open("post", FileController, true);
            xhr.onreadystatechange = function () {
                if(xhr.readyState==4){
                    var ret =JSON.parse(this.response);
                        if(ret.code==1){
                            alert("成功")
                        }
                }
            };
            xhr.send(form);
    }
    else {
            alert("该浏览器不支持,请换Chrome内核浏览器");
    }

 

controller

 $upload = new \Think\Upload (); // 实例化上传类
            $upload->maxSize = 0; // 设置附件上传大小
            $upload->exts = array (
                    'csv'
            ); // 设置附件上传类型
            $upload->rootPath = './Public/uploadFile//'; // 设置附件上传根目录
            $upload->savePath = ''; // 设置附件上传(子)目录
            $now = $_SERVER['REQUEST_TIME'];
                        $upload->saveName = array('uniqid',$now);//防重名的保存规则
                        $info = $upload->upload (); // 上传文件

 

jq 插件化巨坑 loading 拷贝副本替换法

点哪个哪个显示加载

js

//调用
$(even).mini_load();//显示加载
$(even).mini_loaded();//回到原来的样子


$.fn.extend({
    mini_load:function(msg,color){
        var msg=(typeof(msg)=="undefined")?"操作中...":msg;
        var that=$(this);
        var that_copy=$(that).clone();
        var color=(typeof(color)=="undefined")?"white":"black";
        var img_load=document.createElement("span")
        img_load.className="span_loading";
        that_copy.attr("copy","loadingcopy");
        that_copy.html(msg);
        that_copy.prepend(img_load);
        $(that_copy).removeAttr("onclick");
        that.hide();
        that.after(that_copy);
    },
    mini_loaded:function(){
        var that=$(this);
        that.show();
        that.siblings("[copy='loadingcopy']").remove();
    }
})

css

.span_loading{
  background: url(../images/loading-white.gif);
  width:20px;
  height: 20px;
  display: inline-block;
  background-size: 100%;
  vertical-align:middle;
}

 

thinkphp禁止、允许访问模块

// 设置禁止访问的模块列表
'MODULE_DENY_LIST' =>  array('Common','Runtime','Api'),

同样也可设置可以访问的模块和默认模块,代码如下:

'MODULE_ALLOW_LIST'    =>    array('Home','Admin','User'),
'DEFAULT_MODULE'       =>    'Home',

如果项目比较简单,还可以设置单模块,代码如下:

// 关闭多模块访问
'MULTI_MODULE' =&gt; false,
'DEFAULT_MODULE' =&gt; 'Home',

 

h5 video 自定义播放进度条

来源:http://www.cnblogs.com/moqiutao/-风雨后见彩虹

// 为了不随意的创建全局变量,我们将我们的代码放在一个自己调用自己的匿名函数中,这是一个好的编程习惯
        (function(window, document){
            // 获取要操作的元素
            var video = document.getElementById("video");
            var videoControls = document.getElementById("videoControls");
            var videoContainer = document.getElementById("videoContainer");
            var controls = document.getElementById("video_controls");
            var playBtn = document.getElementById("playBtn");
            var fullScreenBtn = document.getElementById("fullScreenBtn");
            var progressWrap = document.getElementById("progressWrap");
            var playProgress = document.getElementById("playProgress");
            var fullScreenFlag = false;
            var progressFlag;

            // 创建我们的操作对象,我们的所有操作都在这个对象上。
            var videoPlayer = {
                init: function(){
                    var that = this;
                    video.removeAttribute("controls");
                    bindEvent(video, "loadeddata", videoPlayer.initControls);
                    videoPlayer.operateControls();
                },
                initControls: function(){
                    videoPlayer.showHideControls();
                },
                showHideControls: function(){
                    bindEvent(video, "mouseover", showControls);
                    bindEvent(videoControls, "mouseover", showControls);
                    bindEvent(video, "mouseout", hideControls);
                    bindEvent(videoControls, "mouseout", hideControls);
                },
                operateControls: function(){
                    bindEvent(playBtn, "click", play);
                    bindEvent(video, "click", play);
                    bindEvent(fullScreenBtn, "click", fullScreen);
                    bindEvent(progressWrap, "mousedown", videoSeek);
                }
            }

            videoPlayer.init();

            // 原生的JavaScript事件绑定函数
            function bindEvent(ele, eventName, func){
                if(window.addEventListener){
                    ele.addEventListener(eventName, func);
                }
                else{
                    ele.attachEvent('on' + eventName, func);
                }
            }
            // 显示video的控制面板
            function showControls(){
                videoControls.style.opacity = 1;
            }
            // 隐藏video的控制面板
            function hideControls(){
                // 为了让控制面板一直出现,我把videoControls.style.opacity的值改为1
                videoControls.style.opacity = 1;
            }
            // 控制video的播放
            function play(){
                if ( video.paused || video.ended ){              
                    if ( video.ended ){ 
                        video.currentTime = 0;
                        } 
                    video.play();
                    playBtn.innerHTML = "暂停"; 
                    progressFlag = setInterval(getProgress, 60);
                } 
                else{ 
                    video.pause(); 
                    playBtn.innerHTML = "播放";
                    clearInterval(progressFlag);
                } 
            }
            // 控制video是否全屏,额这一部分没有实现好,以后有空我会接着研究一下
            function fullScreen(){
                if(fullScreenFlag){
                    videoContainer.webkitCancelFullScreen();
                }
                else{
                    videoContainer.webkitRequestFullscreen();
                }
            }
            // video的播放条
            function getProgress(){
                var percent = video.currentTime / video.duration;
                playProgress.style.width = percent * (progressWrap.offsetWidth) - 2 + "px";
                showProgress.innerHTML = (percent * 100).toFixed(1) + "%";
            }
            // 鼠标在播放条上点击时进行捕获并进行处理
            function videoSeek(e){
                if(video.paused || video.ended){
                    play();
                    enhanceVideoSeek(e);
                }
                else{
                    enhanceVideoSeek(e);
                }

            }
            function enhanceVideoSeek(e){
                clearInterval(progressFlag);
                var length = e.pageX - progressWrap.offsetLeft;
                var percent = length / progressWrap.offsetWidth;
                playProgress.style.width = percent * (progressWrap.offsetWidth) - 2 + "px";
                video.currentTime = percent * video.duration;
                progressFlag = setInterval(getProgress, 60);
            }

        }(this, document))