Wieeinen Klecks auf einen Eingang vom Typ Datei in einem Formular anhängen
// Input of type file
<input type="file" name="uploadedFile" id="uploadedFile" accept="image/*"><br>
// I am getting image from webcam and converting it to a blob
function takepicture() {
canvas.width = width;
canvas.height = height;
canvas.getContext('2d').drawImage(video, 0, 1, width, height);
var data = canvas.toDataURL('image/png');
var dataURL = canvas.toDataURL();
var blob = dataURItoBlob(dataURL);
photo.setAttribute('src', data);
}
function dataURItoBlob(dataURI) {
var binary = atob(dataURI.split(',')[1]);
var array = [];
for(var i = 0; i < binary.length; i++) {
array.push(binary.charCodeAt(i));
return new Blob([new Uint8Array(array)], {type: 'image/jpeg'});
}
// How can I append this var blob to "uploadedFile". I want to add this on form submit
Fügen Sie es zu einem versteckten Eingang hinzu? – Erevald
Warum kommen Sie nach dem ersten Byte in der for-Schleife zurück? – dandavis
@kristijan: Versuchen Sie, 'var blob' in eine SESSION-Variable zu setzen und senden Sie sie, während Sie das Formular absenden. – kmario23