【问题标题】:for yii xupload extensition为你上传扩展
【发布时间】:2013-03-16 05:59:39
【问题描述】:

我想在 xupload 扩展中使用多重属性

我的代码:-

Yii::import("xupload.models.XUploadForm"); 

  $this->widget( 'xupload.XUpload', array(
            'id'=>'uploadwidget',
            'url' => Yii::app( )->createUrl("$mo"),
            'model' => $photo,
            'htmlOptions' => array('id'=>'testmagazines-form'),
            'attribute' => 'file',
            'multiple' => true,
            'options'=>array(
                              'maxNumberOfFiles'=>3,
                              'maxFileSize'=>"js:$('#filesize').val()",
                              'acceptFileTypes'=>"js:/(\.|\/)(jpeg)$/i",

                              'completed' =>"js:function(id, fileName, responseJSON){
                                var value = $('#number').val();
                                var value1 =  parseInt(value) + parseInt(1);
                                $('#number').val(value1);       
                                jQuery(document).trigger('close.facebox');
                                }",
                                'success'=>"js:function(res){ 
                                 var b = $('#number').val();
                                if(b=='1'){ 
                                $('#filesize').val('104857600');

                                }else if(b=='2'){
                                $('#filesize').val('104857600');
                                }else if (b==3){
                                $('#filesize').val('10*1024*1024');
                                }
                                    alert(res[0].mode);
                                }",
                              '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); }"
                                        ),
            )    
        );

在这个我想要每个上传文件的exe。可能会有所不同,所以我该如何处理。

【问题讨论】:

    标签: yii yii-xupload


    【解决方案1】:
    i got a answer for it:-
    

    我可以上传具有多种接受文件类型和大小的多种类型的图像:

    解决方案:-

    在扩展文件夹中找到jquery.fileupload-ui.js:-

    然后在这个js中添加一个参数。

    示例:- pqueryid : 未定义,

            pqueryid1 : undefined,
    
            lqueryid : undefined,
    
            lqueryid1 : undefined,
    
            queryid : undefined,
    
            queryid1 : undefined,
    

    我在运行时需要的所有属性。所以在选项参数中输入一个值。

     add: function (e, data) {
                    var that = $(this).data('fileupload'),
                        options = that.options,
                        files = data.files;
    
                    $(this).fileupload('process', data).done(function () {
                        that._adjustMaxNumberOfFiles(-files.length);
    
                 if(counter==2)
                    {
                    var dataurl ='/project/client/magazinecms/admin/index.php?r=testMagazines/uploadnew&imagename=dev_cert_path&id='+that.options.queryid1+'&queryid='+that.options.queryid+'&m=testMagazines' 
                    that.options.url = dataurl;
                    that.options.acceptFileTypes =/(\.|\/)(pem)$/i;
                    counter--;
                     }else if(counter==1)
                    {
                    var dataurl ='/project/client/magazinecms/admin/index.php?r=testMagazines/uploadnew&imagename=prod_cert_path&id='+that.options.pqueryid1+'&queryid='+that.options.pqueryid+'&m=testMagazines'
                    that.options.url = dataurl;
                    that.options.acceptFileTypes =/(\.|\/)(pem)$/i;
                    counter--;
                    }else{
                    var dataurl ='/project/client/magazinecms/admin/index.php?r=testMagazines/uploadnew&imagename=logo_path&id='+that.options.lqueryid1+'&queryid='+that.options.lqueryid+'&m=testMagazines'
                    that.options.url = dataurl;
                    that.options.acceptFileTypes =/(\.|\/)(jpeg|jpg|png)$/i;
                    counter--;
                    }
    
                        data.isAdjusted = true;
                        data.files.valid = data.isValidated = that._validate(files);
                        data.context = that._renderUpload(files).data('data', data);
                        options.filesContainer[
                            options.prependFiles ? 'prepend' : 'append'
                        ](data.context);
                        that._renderPreviews(files, data.context);
                        that._forceReflow(data.context);
                        that._transition(data.context).done(
                            function () {
                                if ((that._trigger('added', e, data) !== false) &&
                                        (options.autoUpload || data.autoUpload) &&
                                        data.autoUpload !== false && data.isValidated) {
                                    data.submit();
                                }
                            }
                        );
                    });
                }
    

    并在任何需要的地方创建一个函数。 管理它。

    【讨论】:

      猜你喜欢
      • 2018-05-22
      • 1970-01-01
      • 1970-01-01
      • 2013-04-01
      • 2018-01-01
      • 2010-09-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多