Drag and Drop File Preview
How do I make an drag and drop file preview?
Drag an image to the plus button (file input), watch it just be there.. What is a drag and drop file preview? How do you make a drag and drop file preview? This script and codes were developed by Adam Grayson on 10 November 2022, Thursday.
Drag and Drop File Preview - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Drag and Drop File Preview</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="container"> <div class="header"> <h1>Drag & drop image file to the plus button, or click to upload.</h1> </div> <div class="content"> <div class="file-input"> <p>+</p> <input class="image-upload" type="file" accept="image/*;capture=camera"/> </div><img class="image-preview" src="#"/> </div>
</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Drag and Drop File Preview - Script Codes CSS Codes
* { box-sizing: border-box;
}
html, body { font-family: "TrebuchetMS", trebuchet, sans-serif; background-color: #EEEEEF;
}
.container h1 { text-align: center; font-size: 24px; color: #FFFFFF;
}
.header { padding: 50px 0 80px; background-color: #00BCD4;
}
.content { width: 576px; min-height: 64px; background-color: #FFFFFF; margin: -32px auto 0; padding: 5px; position: relative; box-shadow: 0px 4px 12px 0px rgba(0, 0, 0, 0.14);
}
.file-input { position: absolute; top: 0; right: -80px; z-index: 0; width: 64px; height: 64px; background-color: #EEFF41; border-radius: 50%; text-align: center; line-height: 61px; font-size: 50px; color: #000000; box-shadow: 0px 8px 12px 0px rgba(0, 0, 0, 0.14);
}
.file-input input { position: absolute; top: 0; left: 0; z-index: 1; width: 100%; height: 100%; opacity: 0; cursor: pointer;
}
.image-preview { max-width: 100%; display: block;
}
Drag and Drop File Preview - Script Codes JS Codes
(function() { var readFilePath; readFilePath = function(input) { var fileReader; if (input.files && input.files[0]) { fileReader = new FileReader(); fileReader.onload = function(e) { return $('.image-preview').attr('src', e.target.result); }; return fileReader.readAsDataURL(input.files[0]); } }; $('.image-upload').change(function() { return readFilePath(this); });
}).call(this);
Developer | Adam Grayson |
Username | agrayson |
Uploaded | November 10, 2022 |
Rating | 3 |
Size | 3,444 Kb |
Views | 22,264 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Custom Select Element | 3,616 Kb |
Playing Animations on Scroll | 19,876 Kb |
Dynamic circle menus with SASS | 3,928 Kb |
Multi-Column Responsive Carousel | 5,686 Kb |
Dungeon Crawler | 3,644 Kb |
Responsive square grid in pure CSS | 2,140 Kb |
SVG Animation - Circle Fill | 3,322 Kb |
Simple Accordion | 2,952 Kb |
Spinning Circles | 3,581 Kb |
Custom Event Policing | 3,255 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Ocean | Gordonnl | 2,817 Kb |
Horizontal Navigation with Floats | Gymratpacks | 5,403 Kb |
Formations | Cantelope | 5,731 Kb |
Flat buttons for Eliassen.com | Kdooley89 | 1,737 Kb |
SVG Basics | HipsterBrown | 1,852 Kb |
Filter inputs | Rowinf | 1,721 Kb |
E-mail Template | SoloMDFK | 4,871 Kb |
Scarlett Johansson Tribute Page | Diomed | 3,233 Kb |
CSS-Flexbox-Demo | Sstiglets | 1,709 Kb |
IbrahimJabbari-Effect14 | Ibrahimjabbari | 1,919 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!