zoukankan      html  css  js  c++  java
  • 文件上传

    -------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>

  • 相关阅读:
    LeetCode算法题-Sum of Two Integers(Java实现)
    LeetCode算法题-Valid Perfect Square(Java实现-四种解法)
    LeetCode算法题-Intersection of Two Arrays II(Java实现)
    LeetCode算法题-Intersection of Two Arrays(Java实现-四种解法)
    LeetCode算法题-Reverse Vowels of a String(Java实现-四种解法)
    LeetCode算法题-Reverse String(Java实现)
    LeetCode算法题-Power of Four(Java实现-六种解法)
    LeetCode算法题-Power Of Three(Java实现-七种解法)
    添加动态输出 Adding Dynamic Output 精通ASP-NET-MVC-5-弗瑞曼 Listing 2-7
    关于 退步编程 和 退步看书的思考
  • 原文地址:https://www.cnblogs.com/ldms/p/3047615.html
Copyright © 2011-2022 走看看