So, I use FineUploader 3.3 in the MVC 4 application, and this is a very cool plugin that is worth the face value. Thanks for making this very helpful. Now I just need to make it work correctly.
I am new to MVC and absolutely new to JSON passing, so I need help getting this to work. Here is what I use, everything inside doc.ready.
var manualuploader = $('#files-upload').fineUploader({ request: { endpoint: '@Url.Action("UploadFile", "Survey")', customHeaders: { Accept: 'application/json' }, params: { //variables are populated outside of this code snippet surveyInstanceId: (function () { return instance; }), surveyItemResultId: (function () { return surveyItemResultId; }), itemId: (function () { return itemId; }), imageLoopCounter: (function () { return counter++; }) }, validation: { allowedExtensions: ['jpeg', 'jpg', 'gif', 'png', 'bmp'] }, multiple: true, text: { uploadButton: '<i class="icon-plus icon-white"></i>Drop or Select Files' }, callbacks: { onComplete: function(id, fileName, responseJSON) { alert("Success: " + responseJSON.success); if (responseJSON.success) { $('#files-upload').append('<img src="img/success.jpg" alt="' + fileName + '">'); } } } }
EDIT: I used Internet Explorer 9, then switched to Chrome, Firefox, and I can download it just fine. What is needed for IE9? Validation does not work, regardless of browser.
The end point ends, and the file / parameters are filled, so it's all good! Validation does not prevent the user from choosing something outside of this list, but I can work with it for the time being. I can successfully save and do what I need to do with my boot, minus to run OnComplete. In fact, in IE I get the OPEN / SAVE dialog with what I have.
Question: are the parameters of the onComplete function (id, filename, responseJSON) populated with a return or an output? I'm just confused by this. Should my JSON have these parameters in it and populate it?
I do not do this (fill in these parameters), and my C # output method returns a JsonResult that looks like this: just return "success" (if necessary):
return Json(new { success = true });
Do I need to add more? This line after saving occurs, and all I want to do is tell the user that everything is fine or not. Is the "success" property in my Json match the jSON.success response?
What am I missing or wrong? I am sure this will help others too, so I hope you take the time and help. I appreciate it! Thanks.