-1
I am willing to allow the client to change the cover photo of his social network, but I need to make a preview for it.
I can’t put an img tag on it right now 'cause it’s gonna mess up the whole design.
I would like to set the image through the Background-Image property of the DIV parent cover.
Follow the code of how I’m trying to do:
$(function(){
$('#mudarcapa').change(function(){
const file = $(this)[0].files[0]
const fileReader = new FileReader()
fileReader.onloadend = function(){
$('#capa').css("background-image", fileReader.result);
}
fileReader.readAsDataURL(file);
})
})
<label for="mudarcapa" class="mudarcapa">
<a>Adicionar Capa</a>
</label>
<input type="file" name="arquivo" id="mudarcapa">