function initFileUpload(objectContext) { "use strict"; // enforcetrue attribute client support jQuery.validator.addMethod("enforcetrue", function (value, element, param) { return element.checked; }); jQuery.validator.unobtrusive.adapters.addBool("enforcetrue"); $("form#create").data("validator").settings.submitHandler = function (form) { var identifier = $(form).find("input[name='Identifier']").val(); $("
" + "Confirm submitting " + identifier + "
") .dialog({ buttons: { "Confirm": function () { form.submit(); }, "Cancel": function () { $(this).dialog("close"); } } }); }; // 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 = "/umbraco/surface/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 }); }); };