Tôi muốn thực hiện nút tùy chỉnh cho tải lên hình ảnh. Tôi có thể có được kết quả này với bản demo dưới đây:css ẩn nút "Chọn tệp" nhưng hiển thị tệp sau khi chọn
https://jsfiddle.net/algometrix/fgrbyo4z/
Nhưng TÔI CÓ THỂ DISPLAY tên tập tin được lựa chọn sau? Hoặc thậm chí có thể là hình thu nhỏ của hình ảnh nếu có thể? Giống như sau khi tôi chọn một tập tin từ cửa sổ bật mở, tôi muốn nó hiển thị 'tên tập tin' trên trang sau khi tôi chọn nó.
Javascript - jQuery hoàn toàn là một tùy chọn ở đây nếu có ai đó có thể trợ giúp trong khu vực đó.
HTML
<div>
<div style="display:block;text-align:center;margin-top:20%;">
<label for="files"> <span class="btn">Select Image</span></label>
<input style="visibility: hidden; position: absolute;" id="files" class="form-control" type="file" name="files">
</div>
</div>
CSS
.btn {
font-family: Arial;
color: #ffffff;
font-size: 20px;
background: #3f88b8;
padding: 10px 20px 10px 20px;
text-decoration: none;
}
.btn:hover {
background: #3cb0fd;
background-image: -webkit-linear-gradient(top, #3cb0fd, #3498db);
background-image: -moz-linear-gradient(top, #3cb0fd, #3498db);
background-image: -ms-linear-gradient(top, #3cb0fd, #3498db);
background-image: -o-linear-gradient(top, #3cb0fd, #3498db);
background-image: linear-gradient(to bottom, #3cb0fd, #3498db);
text-decoration: none;
}
Javascript. Đó có phải là một lựa chọn không? –
Vâng, rất nhiều! –
Thử các liên kết sau: http://stackoverflow.com/questions/4459379/preview-an-image-before-it-is-uploaded http://stackoverflow.com/questions/12368910/html-display-image-after- select-filename –