How To Copy From Value File Input To Dynamic Input File Value In Java Scripts?
I have a input file multiple choose file, when choosing files in input file multiple divide to the dynamic input file and submit a form to server. Use Asp.net MVC Get all file in
Solution 1:
i try to find new way
Hold on hidden input Base 64 image stream then pass to server in server convert to Image type
jQuery and JS
function readFile(input) {
CheckFileUpload(input.files.length)
if (input.files && input.files[0]) {
var img, inputID = 0;
for (var i = 0; i < input.files.length; i++) {
var reader = new FileReader();
reader.onload = (function (f) {
return function (e) {
//<input type="file" id="file_' + inputID + '" name="file_' + inputID + '" class="d-none" value="' + f + '" style="display:none" />';
var fileInput = $('<input/>')
.attr('type', "hidden")
.attr('name', 'file_' + inputID + '')
.attr('id', 'file_' + inputID + '')
.attr('value', e.target.result);
$('#imgZone').append(fileInput);
inputID++;
}
})(input.files[i]);
reader.readAsDataURL(input.files[i]);
}
}
C#
var filesRequest = Request.Form;
string file = filesRequest["file_1"];
byte[] bytes = Convert.FromBase64String(file); // Replace file here
System.Drawing.Image image;
using (MemoryStream ms = new MemoryStream(bytes))
{
image = System.Drawing.Image.FromStream(ms);
}
Problem in code: Must base 64 string substring or replace data:image/jpeg;base64,
Post a Comment for "How To Copy From Value File Input To Dynamic Input File Value In Java Scripts?"