underbar
underbar

Reputation: 588

Set different url for kendo.ui.upload

I am using the kendo ui upload widget with the django framework to upload a text file to my webserver. On one web page there is two different forms that each use kendo's upload (being used in synchronous mode). When the files are submitted kendo automatically appends 'submit' to the current url and uses that as the url in the post. I would like to be able to dynamically set the url depending on which form is being submitted. Any help would be greatly appreciated.

My form template:

<form method="post" action="submit" class='uploader' style="width:45%">
       {% csrf_token %}
            <div>
                <input name="keywords" id="import-keywords" type="file" />
                <input type="submit" value="Submit" class="k-button" />
            </div>
</form>
...
...
<form method="post">{% csrf_token %}
<div>
    <input name="apps" id="import-apps" type="file" />
    <input type="submit" value="Submit" class="k-button" />
</div>

and my javascript:

$(document).ready(function(){
    $("#import-keywords").kendoUpload({'multiple':false});
    $("#import-apps").kendoUpload({'multiple':false});
})

So in my url file the url that matches (for both forms) is

currentpageurl/submit

Upvotes: 1

Views: 1136

Answers (1)

OnaBai
OnaBai

Reputation: 40887

Actually submit comes from your form. When you say action="submit" you are saying the URL for the post. Since it does not start with / it is relative to your current URL.

If you change it to:

<form method="post" action="foo" class='uploader' style="width:45%">
   {% csrf_token %}
        <div>
            <input name="keywords" id="import-keywords" type="file" />
            <input type="submit" value="Submit" class="k-button" />
        </div>
</form>
...
...
<form method="post" action="bar">{% csrf_token %}
<div>
    <input name="apps" id="import-apps" type="file" />
    <input type="submit" value="Submit" class="k-button" />
</div>

Then you have would be using currentpageurl/foo for the first form (the one that sends import-keywords) and currentpageurl/bar for the second form (the one that sends import-apps).

Upvotes: 2

Related Questions