• 文件上传


    -------iew   

    <?php $this->widget('ext.EAjaxUpload.EAjaxUpload',
            array(
            'id'=>'uploadFile',
            'config'=>array(
                   'action'=>'/developer/space/upload',
                   'allowedExtensions'=>array("jpg","jpeg","gif","png"),//array("jpg","jpeg","gif","exe","mov" and etc...
                   'sizeLimit'=>10*1024*1024,// maximum file size in bytes
                   'minSizeLimit'=>1*1024,// minimum file size in bytes
                   'template'=> '<div class="qq-uploader">' .
                           '<div class="qq-upload-drop-area"><span></span></div>' .
                           '<div  class="qq-upload-button">上传图片</div>' .
                           '<ul class="qq-upload-list" style="display:none;"></ul>' .
                   '</div>',
                    'onProgress' => "js:function(){
                            $('#loading').remove();     
                         var str='<span id=\'loading\' style=\'position:absolute;left:520px;bottom:290px;\'><img src=\'/style/images/loading.gif\'>正在上传,请等待....</span>';
                         $('#uploadFile').append(str);
                    }",
                      'onComplete'=>"js:function(id, fileName, responseJSON){
                              var file = responseJSON.file_url+responseJSON.filename;
                        $('#Space_file').val(file);
                        $('#img_url').attr('src',file);
                        if(responseJSON.success){
                            $('#loading').html('<font color=green>上传成功!</font>');
                        }else{
                            $('#loading').html('<font color=red>上传失败!</font>');
                        }
                   }",
                   // 'messages'=>array(
                        // 'typeError'=>"{file} has invalid extension. Only {extensions} are allowed.",
                        // 'sizeError'=>"{file} is too large, maximum file size is {sizeLimit}.",
                        // 'minSizeError'=>"{file} is too small, minimum file size is {minSizeLimit}.",
                        // 'emptyError'=>"{file} is empty, please select files again without it.",
                        // 'onLeave'=>"The files are being uploaded, if you leave now the upload will be cancelled."
                   // ),
                   // 'showMessage'=>"js:function(message){ alert(message); }"
                  )
            )); ?>

    View 预览

            <div id='tips' style="top:10px"></div>
            <?php
                $widget=$this->beginWidget('ext.quickdlgs.EFancybox',array(
                    'easing'=>true,
                    'contentOptions' => array(
                        'overlayColor' => '#000',
                        'overlayOpacity' => 0.9,
                        'transitionIn' => 'elastic',
                        'transitionOut' => 'elastic',
                        'speedIn' => 600,
                        'speedOut' => 200,
                    ),
                ));
                $cdnurl=Yii::app()->params['cdnImgUrl'].$model->img_path;
                $widget->content('预览',"<img id='img_url' src=$cdnurl >"); //show content in a fancybox
                $this->endWidget();
            ?>
        </div>

  • 相关阅读:
    LINUX系统 下载地址 LINUX镜像站 Centos ubuntu
    LINUX 操作命令大全
    THINKPHP3.2 配置Redis 使用 for windows
    THINKPHP3.2 中使用 soap 连接webservice 解决方案
    THINKPHP3.2+PHP5.3 配置MEMCACHE
    初学C#过程中的记录的一些认为以后有用的东西
    C#面向对象设计模式纵横谈:Builder
    C#面向对象设计模式纵横谈:Singleton
    pattern:Abstract Factory (创建型模式)模式笔记
    数据结构与算法
  • 原文地址:https://www.cnblogs.com/ldms/p/3047615.html
Copyright © 2020-2023  润新知