温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

tp5使用uploadify插件做上传

发布时间:2020-09-26 09:20:39 来源:网络 阅读:2479 作者:woaijorden 栏目:web开发

uploadify插件地址
推荐使用flash版本

插件引入
<script src="../jquery.js"></script>
<script src="../jquery.uploadify.min.js"></script>
<script type="text/javascript">
$(function(){
$("#uploadify").uploadify({
'swf': 'ADMIN/plus/uploadify/uploadify.swf',//所需要的flash文件

             'uploader': "{:url('Cate/upImg')}",//实现上传的程序
             'progressData':'speed',//设置上传进度显示方式,percentage显示上传百分比,speed显示上传速度
             'fileTypeDesc'   : '支持格式:*.jpg;*.jpeg;*.gif;*.png',
             'fileTypeExts': '*.jpg;*.jpeg;*.gif;*.png',//可上传的文件类型

             'buttonText' :'文件上传',//通过文字替换钮扣上的文字
             'buttonClass':'btn btn-xs btn-purple',
             'fileObjName':'img',//文件上传对象的名称,如果命名为’the_files’,PHP程序可以用$_FILES['the_files']来处理上传的文件对象。
             'onUploadSuccess':function(file,data,response){
                            //上传成功后的回调函数
                            var cateImgSrc = "__ROOT__/uploads/cateimg/"+data;

                            var cateimg = "<img height='50' src='"+cateImgSrc+"' >";
                            $('#cateimg').html(cateimg);
                            $("input[name='img']").val(data);
                            if($("input[name='img']").val()!=''){
                                $("#cateimg p").remove();
                            }
                         },
                                         'onSelectError':function(file, errorCode, errorMsg){

                                     switch(errorCode) {
                                         case -110:
                                            layer.alert("图像大小超限,请调低像素后重新上传", {icon: 2});
                                             break;
                                         case -120:
                                            layer.alert("文件 ["+file.name+"] 大小异常!", {icon: 2});
                                             break;
                                         case -130:
                                            layer.alert("文件 ["+file.name+"] 类型不正确!", {icon: 2});
                                             break;
               }}
             });
                 })
向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI