You need to read the contents of the selected file using HTML5 FileReader API then get base64 encoded Data-URL of it. Then you can set this URL as background of anything.
If you don't know Data-URL is a type of URI that does not point to the location of a file, rather it holds the whole content of the file in base64 encoded format inside the URL. Any file can be converted to a Data-URL. You can read more about it here.
Note: Data-URI is only preferred for small files. Do not convert megabyte size files into Data-URI.
function previewFile(fileInput) {
var file = fileInput.files[0];
var reader = new FileReader();
reader.addEventListener("load", function() {
setBackground(reader.result);
}, false);
if (file) {
reader.readAsDataURL(file);
}
}
function setBackground(imageURL){
document.body.style.backgroundImage = "url(" + imageURL + ")";
document.body.style.backgroundSize = "100% auto";
document.body.style.backgroundRepeat = "no-repeat";
document.body.style.backgroundPosition = "center top";
}
<input type="file" onchange="previewFile(this);">