Uploading Image form a file

I want to upload an image via an input field and then display it. How do I make it work.
In principle, I would simply like to upload a picture that serves as a profile picture, which is later saved in a database. But first it should be easy to upload so that it is displayed

function Speichern() {
    var Profilbild = document.getElementById('pb').value;
    var c = Profilbild + ".png"
    document.getElementById('Profilbild').src = c;
}
 <form action=""onsubmit="Speichern();return false">
     <label for="username">Nutzername:</label>
     <input id="username" id="username" type="text" placeholder="<?php
         echo $_SESSION['username']; 
     >">
     <label for="email">Email:</label>
     <input id="email" id="email" type="text" placeholder="<?php
         echo $_SESSION["email"];
     >">
     <label for="pw">Passwort:</label>
     <input id="pw" id="pw" type="password" placeholder="<?php
         echo $_SESSION["pw"];
     >">
     <label for="pb">Profilbild:</label>
     <input type="file" id="pb" name="pb" accept="image/*">
     <button type="submit" >Ändern/Speichern</button>
 </form>
```