如何更改上传器中的 obj 值 (ajax)?

how to change a obj value in the uploader (ajax)?

我仍然尝试通过 js (remotePath) 仅更改此脚本上的 1 个值,请给我信息 :)

谢谢!

$('#uploader_div').ajaxupload(
        {
        url:            'upload.php',
        dropArea:       '#drop_here',
        remotePath:     'user/user1/',  <-- how to change only this value
        ...

像这样

            remotePath:     'user/user2/'

更新:

<div id="uploader_div"></div>
<a id="link" href="#" onclick="newvalue();"> Change user2 </a> <!--Change by Click-->
<script>
    var uplobj = {
        url: 'upload.php',
        dropArea: '#drop_here',
        remotePath: 'user/user1/', // Change by Click
        autoStart: true,
        hideUploadButton: true,
        removeOnSuccess: true, 
        maxConnections: 0,
        maxFileSize: '20M',
        allowExt: ['mp3']
    };
    function newvalue() 
    {
        uplobj.remotePath = 'user/user2/'; // Change by Click
        link.style.display = 'none';
    };    
    $('#uploader_div').ajaxupload(uplobj);
</script>

您可以在 ajax 调用之前随时更改对象,前提是您有对对象的引用。

var obj = {
    url:            'upload.php',
    dropArea:       '#drop_here',
    remotePath:     'user/user1/'
};
obj.remotePath = 'user/user2/';
$('#uploader_div').ajaxupload(obj);

编辑以响应更多代码

我通读了 docs you are supposed to pass a standard jquery options object to ajaxupload. Right now you have a mix of jquery options and the data perhaps see the jquery docs 以了解有关哪些设置有效的更多信息。

一个简单的解决方法可能是将您当前的数据放入数据选项属性中。

$('#uploader_div').ajaxupload({data: obj});