I've been trying to make this work for a little while now.
I thought the following code would work since I'm getting the value from the input and setting the background-image URL to said value.
Thanks!
The code inside of the head tag.
<script type="text/javascript">
function loadImg() {
var imageUrl = $('#hostImage').attr('value')
document.getElementById("upload-success-bg").style.backgroundImage=imageUrl
}
</script>
<style>
#upload-success-bg {
background-image: url();
}
</style>
Input field code
<div class="status">
<input class="image-url" type="text" id="hostImage" name="hostImage" required="true"
value="URL LOADS HERE">
</div>
Where I would like to the image to show
<div class="dropzone upload-success" id="upload-success-bg">
<div class="info"><p>Drag image file here</p><p>Or click here to select image</p></div>
<input type="file" required="" class="input" accept="image/*"></div>
<head>element the element does not yet exist in theDOM, and the function does not appear to be called in the JavaScript at the question. In addition to CSSurl()function not being used to set the value ofbackground-imageproperty.<input type="text">element, and how is the.valueof that element related to the<input type="file">element and displaying an image?<input type="text">element is not necessary. AFileobject does not have a URL property. ABlob URLordata URLcan be created which points to the uploaded file. ABlob URLs lifetime is linked to thedocumentwhich created the URL. Adata URLrepresented adata:,MIMEtype, possibly<charset><base64|text>encoding of the file.