1

我想在 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。可能有所不同,所以我如何处理它。

4

1 回答 1

0
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();
                            }
                        }
                    );
                });
            }

并在任何需要的地方制作功能。管理它。

于 2013-03-20T11:37:46.940 回答