Libraryless. Click here for Pure Java version (2654L/17K).
sS hjs_fileUploadBase64Encoder() { ret hscript([[ var fileConverted = false; function submitWithFileConversion(form) { if (fileConverted) return true; fileConverted = true; var file = $('#fileUploader')[0].files[0]; if (file == null) return true; var reader = new FileReader(); // delay form submit until reader is done reader.onloadend = function () { var b64 = reader.result.replace(/^data:.+;base64,/, ''); $("#f_file_base64").val(b64); console.log("Got base64 data: " + b64.length); setTimeout(function() { $(form).submit(); }, 1000); }; reader.readAsDataURL(file); return false; } ]]); }
Began life as a copy of #1029740
download show line numbers debug dex old transpilations
Travelled to 5 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1029888 |
Snippet name: | hjs_fileUploadBase64Encoder [hjs_imgUploadBase64Encoder with renamed ids] |
Eternal ID of this version: | #1029888/1 |
Text MD5: | e6155c4695b732ea813d4a3270f3bdb7 |
Transpilation MD5: | 2da7317566e7622d56be3ecfec6c0fc1 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-09-27 17:18:57 |
Source code size: | 750 bytes / 26 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 183 / 254 |
Referenced in: | [show references] |