Upload image with preview

Size
2,014 Kb
Views
16,192

How do I make an upload image with preview?

Using javascript to show a preview of the uploaded image.. What is a upload image with preview? How do you make a upload image with preview? This script and codes were developed by Hélio Marcondes on 09 November 2022, Wednesday.

Upload image with preview Previews

Upload image with preview - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Upload image with preview</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <input id="uploadImage" type="file" name="myPhoto" onchange="PreviewImage();" />
<img id="uploadPreview" style="width: 100px; height: 75px;" />
<script type="text/javascript">
function PreviewImage() { var oFReader = new FileReader(); oFReader.readAsDataURL(document.getElementById("uploadImage").files[0]); oFReader.onload = function (oFREvent) { document.getElementById("uploadPreview").src = oFREvent.target.result; };
};
</script> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Upload image with preview - Script Codes CSS Codes

*{ margin:0; padding:0;
}
#uploadPreview{ border:1px solid red; height:200px; width:200px;
}
#uploadImage{ width:200px; float:left;
}

Upload image with preview - Script Codes JS Codes

var oFReader = new FileReader();
oFReader.readAsDataURL(document.getElementById("uploadImage").files[0]);
oFReader.onload = function (oFREvent) {
document.getElementById("uploadPreview").src = oFREvent.target.result;
};
Upload image with preview - Script Codes
Upload image with preview - Script Codes
Home Page Home
Developer Hélio Marcondes
Username haykou
Uploaded November 09, 2022
Rating 3
Size 2,014 Kb
Views 16,192
Do you need developer help for Upload image with preview?

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!

Hélio Marcondes (haykou) Script Codes
Create amazing blog posts with AI!

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!