Intro
I have 3 upload buttons that hide the button just used and gives the option to upload a new pic with a new button (max 3 upload buttons).
I also have a small JavaScript function that shows the image selected (currently only the first button)
Question
How can I add the other two images into this script without repeating code, also is there a way to show file name not the image itself ?
My Code
<script>
document.getElementById("FirstImageID").onchange = function () {
var reader = new FileReader();
reader.onload = function (e) {
// get loaded data and render thumbnail.
document.getElementById("image").src = e.target.result;
};
// read the image file as a data URL.
reader.readAsDataURL(this.files[0]);
};
</script>
<div class="text-center">
<h1 style=" color: blue;">What would you like to do?</h1>
</div>
<div class="form-group" ng-controller="mock-up-makerController">
<div class="controls row center-text">
<input type="file" id="FirstImageID" name="image" class="" accept="image/*"
onchange="angular.element(this).scope().insertImageFirst()"
ng-click=" showDiv1=true"
ng-show="!showDiv1"/>
<!--<input type="file" id="files" />-->
<div ng-show="showDiv1">
<input type="file" id="SecondImageID" name="image" class="" accept="image/*"
onchange="angular.element(this).scope().insertImageSecond()"
ng-click=" showDiv2=true"
ng-show="!showDiv2"/>
</div>
<div ng-show="showDiv2">
<input type="file" id="ThirdImageID" name="image" class="" accept="image/*"
onchange="angular.element(this).scope().insertImageThird()"/>
</div>
</div>
<img id="image" />
</div>