简体   繁体   中英

How to open image in a modal window from html form file type

从表单文件输入中选择图像时,如何在模式弹出窗口中打开图像?

<input type="file" class="form-control">

You can get the Base64 from the input field and then append it to an <img> element, inside your modal. Find details in the link below.

FileReader.readAsDataURL()

You can use fancybox, but if you use base64 encode you have to set some setting for the image...like this:

      <script type="text/javascript">
  $(document).ready(function () {
      $('.fancybox-cs').fancybox({
         type        : 'image'
      });
  });
  </script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM