Skip to main content

How to Build Your Own Image Uploader using HTML, CSS, and JS Tutorial

 

#html #css #foryou #world #happy # website #webdesign #webdeveloper #how to #howto #trending #viral #srilanka #youtube #tiktok #blog  #howtocreate #Javascript #image #imageuploader 


Welcome to our step-by-step tutorial on creating your own image uploader using #html  , #css  , and JavaScript. In this video, we'll guide you through the process of building a simple yet effective image uploader for your web projects. With just a few lines of code, you'll learn how to create a user-friendly interface that allows users to upload images seamlessly. Whether you're a beginner or an experienced developer looking to enhance your skills, this tutorial is perfect for you. Follow along and empower yourself to create dynamic web applications with ease! Don't forget to like, share, and subscribe for more coding tutorials. Let's get started! 

index.html  

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Drag & Drop Image Uploader</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
<div class="main">
    <label for = "input-file" id="area">
        <input type="file" accept="image/*" id="input-file" hidden>
        <div id="img-view">
            <img src="Images/upload.png" width="250px">
            <p>Drag & Drop OR Click Here <br> to Upload Image</p>
            <span>Upload any images from pc</span>
        </div>
    </label>
</div>
</body>
<script src="script.js"></script>
</html>



style.css  
*{
    padding:0;
    margin: 0;
    font-family: 'Poppins',sans-serif;
    box-sizing: border-box;
}
.main{
    width: 100%;
    min-height: 100vh;
    background-color: linear-gradient(rgb(3,128,111),gray);
    display: flex;
    justify-content: center;
    align-items:center;
}
#area{
    width: 500px;
    height: 350px;
    text-align: center;
    background-color: #fff;
    border-radius: 25px;
    padding: 30px;
}
#img-view{
    width: 100%;
    height: 100%;
    border: 2px dotted black;
    border-radius: 25px;
    background: gray;
    background-position: center;
    background-size: cover;
}
#img-view img{
    width: 100px;
    margin-top: 20px;
}
#img-view span{
    font-size: 15px;
    display: block;
    color: black;
    margin-top: 40px;
}




 script.js   

const area = document.getElementById("area");
const inputFile = document.getElementById("input-file");
const imgView = document.getElementById("img-view");

inputFile.addEventListener("change", uploadImage);

function uploadImage(){
    let imgLink = URL.createObjectURL(inputFile.files[0]);
    imgView.style.backgroundImage = `url(${imgLink})`;
    imgView.textContent = "";
    imgView.style.border = 0 ;
}

area.addEventListener("dragover" , function(e){
    e.preventDefault();
});

area.addEventListener("drop", function(e){
    e.preventDefault();
    inputFile.files = e.dataTransfer.files;
    uploadImage();
});










































































































Comments

Popular posts from this blog

Parallax Scrolling Website Effect Using HTML CSS

  Welcome to our step-by-step tutorial on creating Parallax Scrolling Website Effect using #html  & #css  . In this video, we'll guide you through the process of building a simple yet effective Parallax Effect for your web projects. With just a few lines of code, you'll learn how to create a user-friendly interface that allows users to this effect seamlessly. Whether you're a beginner or an experienced developer looking to enhance your skills, this tutorial is perfect for you. Follow along and empower yourself to create dynamic web applications with ease! Don't forget to like, share, and subscribe for more coding tutorials. Let's get started! index.html  <! DOCTYPE html > < html lang = "en" >   < head >     < meta charset = "UTF-8" />     < meta name = "viewport" content = "width=device-width, initial-scale=1.0" />     < title > Parallax Scrolling Website </ title >     ...

How to Create Animate Mic Logo

    Embark on a design and coding adventure with our tutorial on creating and animating a microphone logo using HTML and CSS. In this concise yet comprehensive guide, we'll navigate logo design principles, emphasizing simplicity and visual balance. Seamlessly transitioning to animation, we'll bring the mic logo to life, making it dynamic and engaging. What sets this tutorial apart is its accessibility—no complex software, just the power of code.🎙️✨ #logoanimation #designtutorial #webdevelopment Don't forget to like, share, and subscribe for more web development tutorials and tips. If you have any questions or need further assistance, feel free to leave a comment, and we'll be happy to help you out. Happy coding! Like Us On Facebook:    / codingwithnexusofficial   Follow Us On Instagram:    / coding_with_nexus   Follow Us On TikTok:    / coding.with.nexus  index.html <! DOCTYPE html > < ...

How to Create a Portfolio Web Site

    Unlock the power of web development with our step-by-step guide on building a stunning portfolio website using HTML and CSS! 🚀 Join us on this hands-on journey as we demystify the coding process, This video helps you craft a professional portfolio. Whether you're a beginner or looking to enhance your web development skills, this tutorial is your gateway to creating a standout digital presence. Elevate your portfolio game and showcase your talents to the world! 💻✨ index.html   <! DOCTYPE html > < html lang = "en" > < head >     < meta charset = "UTF-8" >     < meta name = "viewport" content = "width=device-width, initial-scale=1.0" >     < link rel = "stylesheet" href = "style.css" >     < script src = "https://kit.fontawesome.com/b186863b7d.js"     crossorigin = "anonymous" ></ script >     < title > Portfolio Website </ title >...