zoukankan      html  css  js  c++  java
  • thinkphp和uploadfiy

    上传页面 用的是bootstrap

    <div class="col-sm-6"> <div style=" 200px; height: 110px; float: left;"> <input type="hidden" name="photo" value="" id="data_photo" /> <input id="photo_file" name="photo_file" type="file" multiple="true" value="" /> </div> <div style="height: 110px; float: left;"> <img id="upload_img" src="" onerror="this.src='__PUBLIC__/Admin/img/no_img.jpg'" style="height: 100px" /> </div> </div>

      

    $(function(){
    
                $('#photo_file').uploadify({
                    'swf' :'__PUBLIC__/admin/swf/uploadify.swf',  //swf的相对路径
                    'uploader': '{:U("Upload/upload")}',  //后台处理
                    'buttonText': '上传头像', //按钮
                    'height': 35,  //高度
                    'fileTypeExts': '*.gif;*.jpg;*.png',  //上传类型
                    'queueSizeLimit': 1, 
                    'onUploadSuccess': function(file, data, response) { 
    
                        $("#upload_img").attr('src', '__PUBLIC__/Uploads/adminimg/' + data);  //预览效果
                        $("#data_photo").val(data);
                    }
                });
            });

    详细的
    http://www.cnblogs.com/mofish/archive/2012/11/30/2796698.html
    这个非常不错

      

    public function upload(){
            $upload = new ThinkUpload();// ʵ�����ϴ���
            $upload->maxSize   =     3145728 ;// ���ø����ϴ���С
            $upload->exts      =     array('jpg', 'gif', 'png', 'jpeg');// ���ø����ϴ�����
            $upload->rootPath  =     './Public/Uploads/adminimg/'; // ���ø����ϴ���Ŀ¼
            $upload->savePath  =     ''; // ���ø����ϴ����ӣ�Ŀ¼
            // �ϴ��ļ�
            $info   =   $upload->upload();
            if(!$info) {// �ϴ�������ʾ������Ϣ
                $this->error($upload->getError());
            }else{// �ϴ��ɹ�
                foreach($info as $file){
                    echo $file['savepath'].$file['savename'];
                }
            }
    
        }
    

      

  • 相关阅读:
    Git(一):基础调用
    Vue(一):使用Vue创建项目并发布
    mysql用户与权限
    跨域理解及常用解决方案
    Ajax简单用法
    冒泡排序算法
    委托使用方式
    How to: Add the Analyze Action to List Views 如何:将分析按钮添加到列表视图
    How to:Customize Action Controls 如何:自定义按钮控件
    How to: Customize the New Action's Items List 如何:自定义新按钮的项目列表
  • 原文地址:https://www.cnblogs.com/mengluo/p/5485832.html
Copyright © 2011-2022 走看看