Click here to Skip to main content
15,881,089 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I am facing problem with Jquery FileUpload plugin with MVC 5. I have 3 FileUpload into My one form. All are with dropzone. When i drag or upload on image into first dropzone, image should display into dropzone first. But when i tried to drag or upload image into dropzone 2, image render into dropzone 1 instead of dropzone 2.


Please help me to solve this issue.

Also i want all the files which are uploaded in all dropzone into the controller on button click.

Thanks in advance.

Regards,
Tejash
Posted
Updated 27-Mar-15 4:58am
v2
Comments
Pheonyx 27-Mar-15 18:22pm    
Do you have any sample code so we can see how you are using it?
TejashDesai 28-Mar-15 1:49am    
<form id="fileupload" method="POST" enctype="multipart/form-data">
<div class="row fileupload-buttonbar">
<div class="col-lg-7">
<!-- The fileinput-button span is used to style the file input field as button -->

<button class="btn btn-primary start">

<span>Start upload</span>
</button>
</div>
</div>
<!-- The table listing the files available for upload/download -->
<div role="presentation" class="test" id="file-list1">
<div id="filelist1" class="files dropzone fileinput-button" style="border: 1px dashed; height: 150px; text-align: center; width: 150px;" data-toggle="modal-gallery" data-target="#modal-gallery">
<input type="file" name="Files1[]" multiple title="Add file for processing1" />
</div>
</div>

<div role="presentation" class="test" id="file-list2" style="display:none;">
<div id="filelist2" class="files dropzone fileinput-button" style="border: 1px dashed; height: 150px; text-align: center; width: 150px;" data-toggle="modal-gallery" data-target="#modal-gallery">
<input type="file" name="Files2[]" multiple title="Add file for processing2" />
</div>
</div>
</form>

There are right now two dropzone. I found that Jquery Fileupload plugin works on "files" class. I have created one Fileupload widget as follow:
$('#fileupload').fileupload({
downloadTemplateId: null,
uploadTemplateId: null,
fileInput: $("input:file"),
url: url,
autoUpload: false,
previewMaxWidth: 120,
previewMaxHeight: 90,
acceptFileTypes: /(\.|\/)(gif|jpe?g|png|bmp)$/i,
maxFileSize: 10240000,
minFileSize: undefined,
maxNumberOfFiles: 20,
done: function (e, data) {
$.each(data.result, function (index, file) {
$('<p/>').text(file.name).appendTo(document.body);
});
},
uploadTemplate: function (o) {
var rows = $();
$.each(o.files, function (index, file) {
$('.template-upload').remove();
var row = $('<div class="template-upload fade"><div>' +
'<span class="preview"></span></div>' +
(!index && !o.options.autoUpload ?
'<button type="button" class="btn btn-primary start" data-dismiss="modal" aria-label="Close" disabled style="display:none;" ><span aria-hidden="true">×</span></button>' : '') +
'</div>');
if (file.error) {
row.find('.error').text(file.error);
row.find('.start').addClass("disabled");
}
rows = rows.add(row);
});
$('#file-list2').show();
return rows;
}
})
.on("fileuploadadd", function (e, data) {
filesList.push(data.files[0]);
});

I want to create different fileupload widget for every dropzone in one form.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900