I'm trying to add an image as a background for the html page if the user wants to change.So what I did is, I used input file type to access the local folder and I can also make them to select the image whatever they want. But now I want to how can I make the image which was selected by the user to make it fixed as the page backgroundImage. Here is my code.This is mostly like a desktop background or smartphone wallpaper.
index.html
<!DOCTYPE html>
<html>
<head>
<title>Understanding File upload and File access Javascript</title>
</head>
<body>
<input type = "file" id = "files" name = "files[]" multiple></input>
<output id = "list"></output>
</body>
<script src = "fileaccess.js" type = "text/javascript"></script>
</html>
fileaccess.js
if(window.File && window.FileReader && window.FileList && window.Blob){
alert("Yes, its supported in this browser");
}else{
alert('The File APIs are not fully supported in this browser.');
}
function handleFileSelect(evt){
var files = evt.target.files;
var output = [];
for(var i = 0, f; f = files[i]; i++){
output.push('<li><strong>', escape(f.name), '</strong> (', f.type || 'n/a',') - ',
f.size, 'bytes, last modified: ',
f.lastModifiedDate ? f.lastModifiedDate.toLocaleDateString() : 'n/a',
'</li>');
}
document.getElementById('list').innerHTML = '<ul>' + output.join('') + '</ul>';
}
document.getElementById('files').addEventListener('change', handleFileSelect, false);
Please give some help!