简体   繁体   中英

add base64 decoded picture to upload form field

Is there a way to add encoded image to the form taken from webcam? I can print image for prewiew, but I need to upload to the server, I have upload form for images, so I need to use same form for uploading camera images (if possible).

 var result = cameraApi.save();
 $('.items-list').append('<img src=data:image/jpeg;base64,' + result + ' />');

This code is for displaying taken image, please advice how to instantly add it to upload form.

You can't add random files to <input type="file"> controls. That's basic browser security, so sites cannot steal files in your hard disk.

But you don't need an upload control at all if you already have the file contents in a JavaScript variable! Just add it to a hidden field or make an AJAX post request.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM