关于使用 plupload 上传组件实时修改里面的参数问题

小弟我JS菜鸟一枚,最近几天将swfupload 替换为 plupload ,遇到很多的问题,目前主要就是这个一个,先帖代码:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>上传</title>
<script src="/js/jquery.min.js"></script>
<link href="/js/jquery-ui/jquery-ui.css" rel="stylesheet" type="text/css" />
<link href="/js/plupload/jquery.ui.plupload/css/jquery.ui.plupload.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/js/jquery-ui/jquery-ui.min.js"></script>
<script type="text/javascript" src="/js/plupload/plupload.full.min.js"></script>
<script type="text/javascript" src="/js/plupload/jquery.ui.plupload/jquery.ui.plupload.js"></script>
<script type="text/javascript" src="/js/plupload/i18n/zh_cn.js"></script>
<script type="text/javascript">
var uplodfiles = "";
var filenames = "";
$(function() {
    var uploader = $("#uploader").plupload({
        runtimes: "html5,flash,silverlight,html4",
        url: "up.php?dosubmit=1",
        max_file_count: 10,
        chunk_size: "20 MB",
        filters: {max_file_size: "2 MB", mime_types: [{title: "图片",extensions: "gif,bmp,jpg,jpeg,png"}]},
        init: {
            FileUploaded: function(up, file, info) {
                myres = JSON.parse(info.response);
                if (myres["error"]) {
                    alert(myres["error"]["message"]);
                    return;
                }
                if(myres["result"]) {
                    uplodfiles += myres["result"]+"|";
                }
            },
        },
        multipart_params: {"watermark_enable": "1","isadmin":"1","dosubmit":"1"},
        rename: true,
        sortable: true,
        dragdrop: true,
        views: {list: true, thumbs: true, active: "thumbs"},
        flash_swf_url: "/js/plupload/Moxie.swf",
        silverlight_xap_url: "/js/plupload/Moxie.xap"
    });
});
</script>
<div><input type="checkbox" id="watermark_enable" value="1" checked onclick="change_watermark()">是否添加水印</div>
<div id="uploader"><p>你的浏览器不支持 Flash, Silverlight, Gears, BrowserPlus 或者 HTML5</p></div>
</body>
<script type="text/javascript">
function change_watermark(){
    if($('#watermark_enable').attr('checked')) {
        //把multipart_params 里面的watermark_enable的值 改变为1 
    } else {
        //把multipart_params 里面的watermark_enable的值 改变为10
    }
}
</script>
</html>

点击 “是否添加水印”就可以实时取消和打开水印功能,这个multipart_params会把里面的参数POST到PHP,watermark_enable参数默认为1,为0就是关闭。现在问题来了------怎么更改 multipart_params 里面参数watermark_enable的值,请大神们帖代码,小弟JS菜鸟一枚。

阅读 3.8k
评论
    1 个回答
      撰写回答

      登录后参与交流、获取后续更新提醒