I'm trying to use to allow the user to upload an image that will be used as a background. I don't know if I need to get the full path of the file.
This is the input I'm trying to use:
This is the JavaScript associated with the input
Background = selectBackground.value; document.body.style.background = "#4d3325 url('" background "') No repeating center center fixed"; document.body.style.backgroundSize = "Auto 100%";
The background doesn't change at all, when I try to display it as a regular image it just displays a small image icon.
Hi friends, please check if this solution meets your needs:
Use URL.createObjectURL()
By using this function, the uploaded image file will be converted into an object url.
Finally, when we change other images, we should use
URL.revokeObjectURL()
to remove the old url from memory for better memory management.