Add backload
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
function initFileUpload(objectContext) {
|
||||
"use strict";
|
||||
|
||||
// We use the upload handler integrated into Backload:
|
||||
// In this example we set an objectContect (id) in the url query (or as form parameter).
|
||||
// You can use a user id as objectContext give users only access to their own uploads.
|
||||
var url = "/Backload/FileHandler?objectContext=" + objectContext;
|
||||
|
||||
// Initialize the jQuery File Upload widget:
|
||||
$("#fileupload").fileupload({
|
||||
url: url,
|
||||
autoUpload: true,
|
||||
maxFileSize: 5000000,
|
||||
maxChunkSize: 10000000, // Optional: file chunking with 10MB chunks
|
||||
acceptFileTypes: /(csv)$/i // Allowed file types
|
||||
})
|
||||
.bind("fileuploadsubmit", function (e, data) {
|
||||
// Optional: We add a random uuid form parameter. On chunk uploads the uuid is used to store the chunks.
|
||||
//data.formData = { uuid: Math.random().toString(36).substr(2, 8) };
|
||||
});
|
||||
|
||||
// Load existing files:
|
||||
$("#fileupload").addClass("fileupload-processing");
|
||||
$.ajax({
|
||||
url: url,
|
||||
dataType: "json",
|
||||
context: $("#fileupload")[0]
|
||||
}).always(function () {
|
||||
$(this).removeClass("fileupload-processing");
|
||||
}).done(function (result) {
|
||||
$(this).fileupload("option", "done")
|
||||
.call(this, $.Event("done"), { result: result });
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user