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


i want able take base64 encoded string , mimic if file selected "browse" feature. here short example:

<input type="file" id="file" />   <script>     //i want able access here     $("#file").files; </script> 

i want able access files array , use normal file. base64 encoded string so:

// resize canvas , draw image data 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); // actual resized preview var base64string =  canvas.todataurl("image/jpeg", 0.7); 

file elements usable user, need transfer base64 string normal form submission , decode on server.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -