screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Image to Base64</title> </head> <body> <h1>Javascript Convert Image to Bas64 String</h1> <input type="file" id="imageInput" onchange="convertToBase64()"> <textarea id="base64Output" rows="10" cols="50"></textarea> <script> 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; } if (file) { reader.readAsDataURL(file); } else { output.value = "Please select an image."; } } </script> </body> </html>