2

i still try to change just 1 value on thish Script via js (remotePath), please give me informations :)

Thank you!

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

like this

            remotePath:     'user/user2/'

Update:

<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>
t3dodson
  • 3,949
  • 2
  • 29
  • 40
mister32
  • 59
  • 7

1 Answers1

2

You can change an object anytime before the ajax call if you have a reference to it.

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

EDIT in response to more code

I read through the 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 for more info on what settings are valid.

A simple fix might be putting your current data in the data options attribute.

$('#uploader_div').ajaxupload({data: obj});
t3dodson
  • 3,949
  • 2
  • 29
  • 40
  • thank you its works but not in js function :( function newvalue() { uplobj.remotePath= 'user/user2/'; } – mister32 Jun 01 '15 at 00:46
  • You need a reference to the object that you are passing to ajaxupload. I will need to see more of your code to be able to help you figure out whats wrong exactly. – t3dodson Jun 01 '15 at 02:15
  • thank you but it does not .woeks so that no data will be loaded – mister32 Jun 01 '15 at 04:32