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>

  • 相关阅读:
    内存映射文件原理探索(转载)
    虚拟内存原理
    CSAPP-链接
    CSAPP-程序优化
    CSAPP-过程调用,数据存储,缓冲区溢出
    【数学,方差运用,暴力求解】hdu-5037 Galaxy (2014鞍山现场)
    【贪心+一点小思路】Zoj
    【几何模板加点小思路】hdu-4998 Rotate
    【背包问题】【出来混总是要还的...】总结+入门练手题
    【优先队列】【最近连STL都写不出来了/(ㄒoㄒ)/~~】hdu_5360/多校#6_1008
  • 原文地址:https://www.cnblogs.com/ldms/p/3047615.html
Copyright © 2011-2022 走看看