c# - Dropzone with some other parameters -
i upload image using dropzone.i need send other values via that(some text values).in scenario need send product name controller(pls see comment in code)
image comes controller's side,when buttton click.
html code
<input type="text" name="text" id="txtprod" class="form-control" /> <div id="dropzonffe" style="width: 55%; margin-left: 25%"> <form action="~/admin/saveproducts" class="dropzone" id="dropzonejsform"></form> </div>
jquery code
<script type="text/javascript"> dropzone.options.dropzonejsform = { autoprocessqueue: false, init: function () { var submitbutton = document.queryselector("#btnsubmit"); var mydropzone = this; submitbutton.addeventlistener("click", function () { var productname = $("#txtprod").val();//<-- want send productname controller also. mydropzone.processqueue(); }); } }; </script>
my controller
public actionresult saveproducts() { bool issavedsuccessfully = false; foreach (string filename in request.files) { httppostedfilebase file = request.files[filename]; issavedsuccessfully = true; } return json(new { issavedsuccessfully, jsonrequestbehavior.allowget }); }
- i need pass product name controller. how can ?
i found solution problem.here have paste future help.there's event in dropzone called sending
.you can pass additional parameters via append form data.
dropzone.options.dropzonejsform = { autoprocessqueue: false, init: function () { var submitbutton = document.queryselector("#btnsubmit"); var mydropzone = this; this.on("sending", function (file, xhr, formdata) { formdata.append("productname", $("#txtprod").val()); }); submitbutton.addeventlistener("click", function () { mydropzone.processqueue(); }); } };
access in server side
public actionresult saveproducts(string productname) { }