How to convert base64 encoded string into a file input to be uploaded as an image

I want to be able to take a base64 encoded string and mimic it as if it were a file that i selected it from the "browse" feature. Here is a short example:

<input type="file" id="file" />

    //I want to be able to access it here

I want to be able to access the files array and use it as a normal file. I currently get the base64 encoded string like so:

// resize the canvas and draw the image data into it
var canvas = document.createElement('canvas');
canvas.width = width;
canvas.height = height;
var ctx = canvas.getContext("2d");
ctx.drawImage(img, 0, 0, width, height);
preview.appendChild(canvas); // do the actual resized preview
var base64String =  canvas.toDataURL("image/jpeg", 0.7);


File elements are only usable by the user, you would need to transfer the base64 string as normal form submission and then decode it on the server.

Need Your Help

Why is this an endless for loop


I just went through the Looping Techniques Chapter of the python docs tutorial and I have a question regarding this boy here: [:]

How to use several databases with Spring MVC and Hibernate?

hibernate spring spring-mvc

For example I have one class mapped to a table in first database and the second class mapped to a table in the second database.