Skip to content

Instantly share code, notes, and snippets.

@kayode-adechinan
Created January 30, 2020 12:13
Show Gist options
  • Save kayode-adechinan/c24e7e4d09fab806767a9dd953308ae8 to your computer and use it in GitHub Desktop.
Save kayode-adechinan/c24e7e4d09fab806767a9dd953308ae8 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="output"/>
<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 () {
var output = document.getElementById('output');
output.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