1
I’m making a preview, and it’s happening like this, I want it to not appear as if it had no image, and only appear the preview image when the user chooses the image.
It’s getting like this before I put the image, but I want it not to have this shape without image:
Code:
Javascript
var loadFile = function(event) {
var output = document.getElementById('output');
output.src = URL.createObjectURL(event.target.files[0]);
}
HTML that takes the image and shows
<img id="output" style="width:100%;height:250px;padding:10px 10px 10px 10px;"/>
<br>
<br>
<input type="file" name="img" id="img" accept="image/jpg, image/jpeg, image/png" onchange="loadFile(event)"/>
<br/><br/>
I tried to do this, but it turns out that this is in Laravel
– Victor Gabriel
and then you’re not accepting when I try to put an img
– Victor Gabriel
What if you put it in javascript? when you start the document change the image’s SRC? If it doesn’t work I think you’ll have to really hide the image, maybe with a CSS class and then when you set the output SRC add also to the output the class that would make the image visible or just a display:block;. Do you understand what I mean? I don’t know if it’s possible in the Atlantic to do this, I have little experience with it.
– Henrique Pauli