<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Image to Base64</title>
<h1>Javascript Convert Image to Bas64 String</h1>
<input type="file" id="imageInput" onchange="convertToBase64()">
<textarea id="base64Output" rows="10" cols="50"></textarea>
function convertToBase64() {
const input = document.getElementById('imageInput');
const output = document.getElementById('base64Output');
const file = input.files[0];
const reader = new FileReader();
reader.onloadend = function () {
output.value = reader.result;
reader.readAsDataURL(file);
output.value = "Please select an image.";