I have customized my form upload button and hide the input
field via css display:none
but when I select an image the input is not showing the preview text!
I want to display the selected image preview text so that user know he has selected an image!
HTML:
<div class="form-group">
<label for="before_image" class="custom-file-upload"><i class="fa fa-cloud-upload"></i> Before Image*</label>
<input type="file" id="before_image" name="before_image" class="form-group" placeholder="Before Image" data-bind="value: before_image">
<span>No file chosen</span>
</div>
CSS:
.custom-file-upload {
border: 1px solid #ccc;
display: inline-block;
padding: 6px 12px;
cursor: pointer;
}
input[type=file] {
display: none;
}
input[type=file]{
display:none;
}
.custom-file-upload {
border: 1px solid #ccc;
display: inline-block;
padding: 6px 12px;
cursor: pointer;
}
<div class="form-group">
<label for="before_image" class="custom-file-upload"><i class="fa fa-cloud-upload"></i> Before Image*</label>
<input type="file" id="before_image" name="before_image" class="form-group" placeholder="Before Image" data-bind="value: before_image"> <span>No file chosen</span>
</div>
UPDATE: I tried all these solutions (How to display file name for custom styled input file using jquery?) but none worked for me. In my scenario I have two upload buttons one is before image upload
and second is after image upload
as shown in video.
Still I can't display the preview text in front of the upload buttons.