24 Nisan 2024 01:36, Çarşamba 1602 0
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>RESİM ÖNİZLEME</title> <style type="text/css"> body { width:100%; margin:0; height:100vh; display: flex; align-items: center; flex-direction: column; padding-top:5rem; background: #fff; font-family:verdana } .preview { width:30rem; min-height:10rem; margin-top:2rem; border:1px solid #eee; color:#eee; display: flex; justify-content: center; align-items: center; font-size: 3rem; } input { width:30rem; font-size: 0.8rem; border: 1px solid #ddd; cursor:pointer; background: #eee; } input:hover { border-color: #000; } input::file-selector-button { background: #dd3a00; color: #fff; padding: 1rem 2rem; border:none; cursor:pointer; } img {width:100%;} @media(max-width:600px) {html{font-size:11px}} </style> </head> <body> <input type="file" id="image" /> <div class="preview"> RESİM ÖNİZLEME </div> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script> <script type="text/javascript"> $("#image").change(function(){ var image=document.querySelector("#image"); if (image.files){ var veri=new FileReader(); veri.onload=function() { var link=veri.result; $('.preview').html('<img src="'+link+'"/>'); } veri.readAsDataURL(image.files[0]); } }); </script> </body> </html>
Toplam 7 Makale
Lütfen yorumlarınızda saygılı, yapıcı ve anlaşılır bir dil kullanın. Küfür, hakaret ya da spam içerikler onaylanmaz.