I want to use Krajee bootstrap-fileinput (http://plugins.krajee.com/file-input) with Mvc razor, Please help me out with the process to to upload images to server and json result from actionResult.
I have just included a required js and css files in my view page and added a line
<input id="input-702" name="kartik-input-702[]" type="file" multiple="true" class="file-loading">
and a script
$("#input-702").fileinput({
uploadUrl:"@Url.Action("upload","Home")",
uploadAsync: true,
minFileCount: 1,
maxFileCount: 5,
overwriteInitial: false,
initialPreview: "",
initialPreviewConfig:"",
uploadExtraData: ""
});
This line is getting formatted and showing a drag and drop effect and select file button.The file selection and Thumbnail creation is working properly but on upload action there is the (fileinput,js) function "ajaxSubmit" which use to post the content to HomeController ActionResult "Upload".
ajaxSubmit: function (fnBefore, fnSuccess, fnComplete, fnError) {
var self = this, settings;
self.uploadExtra();
settings = $.extend({
xhr: function () {
var xhrobj = $.ajaxSettings.xhr();
return self.initXhr(xhrobj, 98);
},
url: self.uploadUrl,
type: 'POST',
dataType: 'json',
data: self.formdata,
cache: false,
processData: false,
contentType: false,
beforeSend: fnBefore,
success: fnSuccess,
complete: fnComplete,
error: fnError
}, self.ajaxSettings);
self.ajaxRequests.push($.ajax(settings));
},
Now i want to save all the files to server which are not uploaded using ActionResult and pass a value back to js. how to retrieve formdata and process.??
I have a similar problem. Got it working (with the ajax calls) but always get one file in the request (whereas I need to get multiple but should be working for you!)
My code is as follows: HTML:
JS:
MVC controller which I would expect to be working - but i not:
However when in side the method I will call:
My scenerio is that user:
The only way I figure it, how it could be working is the ajax call switch on the plugin which allows to append the preview list. Unfortunatelly I can't submit all the pictures to the controller then.
I was trying to find the solution to above problem and finally found the one. As I am able to save the file at server location from the controller but unfortunately I could not send the json response from controller to javascript.
Saving image using controller action :
To implement the delete button we have to Send Data from server in Asynchronous mode as a json array object eg.
Can anybody help me out to create json array object in controller and send it as a response object.???