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'];
                }
            }
    
        }
    

      

  • 相关阅读:
    vue搭建开发环境
    一些意想不到的小bug。
    小程序开发中遇到的问题
    Per相关图书推荐
    MATLAB相关图书推荐
    CSS相关图书推荐
    Cocos2d相关图书推荐
    JSP相关图书推荐
    Fortran相关图书推荐
    R语言相关图书推荐
  • 原文地址:https://www.cnblogs.com/mengluo/p/5485832.html
Copyright © 2011-2022 走看看