Skip to content

Commit 99c31e3

Browse files
committed
Url can be a function as well as string
1 parent 33ce2c7 commit 99c31e3

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

example.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
<script type="text/javascript">
1818
$(function() {
1919
$("#upload_field").html5_upload({
20-
url: '/',
20+
url: function() {
21+
return prompt("Url", "/");
22+
},
2123
onStart: function(event, total) {
2224
return confirm("You are trying to upload " + total + " files. Are you sure?");
2325
},

jquery.html5_upload.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
upload_file(number+1);
111111
}
112112
};
113-
xhr.open("post", options.url, true);
113+
xhr.open("post", typeof(options.url) == "function" ? options.url() : options.url, true);
114114
xhr.setRequestHeader("Cache-Control", "no-cache");
115115
xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
116116
xhr.setRequestHeader("X-File-Name", file.fileName);

0 commit comments

Comments
 (0)