My web page has an "upload image" placeholder image by default. I want the user to be able to upload an image and have a javascript function call change the image "images/upload_wText.png" in the code below to whatever image file they chose. I've seen several similar questions (and answers) on SO but they don't exactly address what I'm trying to accomplish. I have tried tweaking the some of the solutions but nothing has worked. This is for a school programming assignment and we are not allowed to use jQuery. Any suggestions?
<div class="uploadImgContainer" id="uploadImgCont">
<img src="images/upload_wText.png" alt="upload button"/>
</div>
<div class="uploadButtonContainer">
<input type = "file" id="uploadImageBtn" onchange="uploadPetImg(this);"/>
</div>
javascript code:
function uploadPetImg(myImagePath) {
document.getElementById("uploadImgCont").src = myImagePath;
}