Search
 
SCRIPT & CODE EXAMPLE
 

HTML

how to convert input type file into an icon

<div class="image-upload">
      <label for="file-input">
        <img id="previewImg" src="https://icon-library.net/images/upload-photo-icon/upload-photo-icon-21.jpg" style="width: 100px; height: 100px;" />
      </label>

      <input id="file-input" type="file" onchange="previewFile(this);" style="display: none;" />
    </div>




<script>
        function previewFile(input){
            var file = $("input[type=file]").get(0).files[0];

            if(file){
              var reader = new FileReader();

              reader.onload = function(){
                  $("#previewImg").attr("src", reader.result);
              }

              reader.readAsDataURL(file);
            }
        }
    </script>
Comment

PREVIOUS NEXT
Code Example
Html :: make text blue html 
Html :: how to add a link in image 
Html :: how to set a gif as a background image of a page 
Html :: how to create table row in javascript 
Html :: a open in new tab 
Html :: bulma upload file 
Html :: ion-select cancel text 
Html :: html redirecting to previous page 
Html :: how to disable a link 
Html :: getproductpricehtml magento 2 
Html :: info symbol text 
Html :: how to define tag icon in html 
Html :: html <footer element 
Html :: align buttons next to each other bootstrap 
Html :: Disable right click on your webpage 
Html :: html checkbox 
Html :: what kind of cancer did technoblade get 
Html :: toggle font awesome icon 
Html :: svg xlink 
Html :: how to make list in html 
Html :: how to download folder using scp 
Html :: chevron down html 
Html :: html highlight text 
Html :: times hmrl 
Html :: access particular array index in html template django 
Html :: embed maps responsive 
Html :: fixed footer button css 
Html :: how to set logo in html in header 
Html :: html textboxes 
Html :: select placeholder 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =