danielm / uploader

A lightweight and very configurable jQuery plugin for file uploading using ajax(a sync); includes support for queues, progress tracking and drag and drop.
https://danielmg.org/demo/java-script/uploader
MIT License
1.17k stars 384 forks source link

Dynamic URL for POST'in #78

Open prabhupravin opened 6 years ago

prabhupravin commented 6 years ago

Hi,

i might need to upload a file to different URLs basis of a radio button selected on screen

for e.g. if CSV is selected then i upload to 'upload/csv' if XLS is selected then i uploads to 'upload/xls'

is this possible in the current release?

Regards, Pravin

mcorten commented 6 years ago

As far as i can see, at this moment it is not possible. Possible solutions: 1: fork the project and add a setUrl() method in DmUploader.prototype.methods, make sure to check if upload widget is idle

2: initialize 2 uploaders on different divs, hide or show the divs on radio button change

reason211 commented 6 years ago

Replace

// Ajax Submit
    file.jqXHR = $.ajax({ 
      url: file.widget.settings.url,

to

var _url = '';  
 if(  typeof(file.widget.settings.url)  === 'function'){  
        _url = file.widget.settings.url();  
    }else{  
        _url = file.widget.settings.url;  
    }  
    // Ajax Submit  
    file.jqXHR = $.ajax({  
      url: _url,

Then

$('.xxxx').dmUploader({  
      url: function(){  
        return url + '?id=' + $('.yyyy').val();  
      },
SapientHetero commented 6 years ago

$('#drag-and-drop-zone').dmUploader().data().settings.url=[insert url here];

itonohito commented 2 years ago

$('#drag-and-drop-zone').dmUploader().data().settings.url=[insert url here];

Doesn't work for me.