forked from maccman/holla
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjquery.upload.js
More file actions
33 lines (26 loc) · 768 Bytes
/
Copy pathjquery.upload.js
File metadata and controls
33 lines (26 loc) · 768 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
(function($){
var uploadDefaults = {
progress: $.noop,
load: $.noop,
method: "POST"
};
$.upload = function(file, options){
options = $.extend( {}, uploadDefaults, options);
$.ajax({
url: options.url,
type: options.method,
success: options.success,
processData: false,
contentType: "multipart/form-data",
beforeSend: function(xhr){
var upload = xhr.upload;
upload.addEventListener("progress", options.progress, false);
upload.addEventListener("load", options.load, false);
xhr.setRequestHeader("Cache-Control", "no-cache");
xhr.setRequestHeader("X-File-Name", file.fileName);
xhr.setRequestHeader("X-File-Size", file.fileSize);
},
data: file
});
};
})(jQuery);