Skip to content

Instantly share code, notes, and snippets.

@kayode-adechinan
Last active January 30, 2020 12:20
Show Gist options
  • Save kayode-adechinan/9e7cabbf3f090b5c0588cfd5c51f34cd to your computer and use it in GitHub Desktop.
Save kayode-adechinan/9e7cabbf3f090b5c0588cfd5c51f34cd to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>repl.it</title>
</head>
<body>
<div>Click the upload icon below to upload a file.</div>
<img
id="imgFileUpload"
alt="Select File"
title="Select File"
src="https://speckyboy.com/wp-content/uploads/2017/12/open-source-file-upload-fields-thumb.png"
width="100"
height="100"
style="cursor: pointer"
/>
<br />
<span id="spnFilePath"></span>
<input type="file" id="FileUpload1" style="display: none" />
<script type="text/javascript">
window.onload = function() {
var fileupload = document.getElementById("FileUpload1");
var filePath = document.getElementById("spnFilePath");
var image = document.getElementById("imgFileUpload");
image.onclick = function() {
fileupload.click();
};
fileupload.onchange = function() {
image.src = URL.createObjectURL(event.target.files[0]);
};
};
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment