I'm currently trying to create code which allows the user to pass an image path through a file input box and then change thhe image src to that file using JavaScript. My code tries to accomplish this through getting the file input path, saving that in a variable then getting the element of the picture the user should be able to change and changing the src of that elemant to the file path. However, this doesn't seem to work and returns the alt of the image instead. My code is:
function upload(){
var fileinput = document.getElementById("image");
document.getElementById("pic").src=fileinput;
}
The image is:
<img class="profile_pic" id="pic" src="../Images/guitar.jpg" alt="Profile Picture">
and the input html:
`<input type="file" multiple="false" accept="image/* name="image" id="image" class="manage_account_textbox"/><br>
<button class="upload_image_button" onclick="upload()">Confirm Changes</button>