首页 > 解决方案 > 如何覆盖徽标

问题描述

我想通过徽标上的预览照片删除徽标在此处输入图像描述 ,我的脚本是

        function preview_image(event)
        {
         var reader = new FileReader();
         reader.onload = function()
         {
          var output = document.getElementById('output_image');
          output.src = reader.result;
         }
         reader.readAsDataURL(event.target.files[0]);
        }
<label for="id_Photo"><img height="120" width="120" alt="Image description" src="{% static 'images/imglogo.png' %}"></label>
        <input type="file" name="Photo" required="" id="id_Photo" style="display:none" onchange="preview_image(event)">
        <img height="120" width="120" id="output_image"/>

标签: javascripthtmldjango

解决方案


尝试

<label for="id_Photo"><img  id="output_image" height="120" width="120" alt="Image description" src="{% static 'images/imglogo.png' %}"></label>
            <input type="file" name="Photo" required="" id="id_Photo" style="display:none" onchange="preview_image(event)">
       

代替

<label for="id_Photo"><img height="120" width="120" alt="Image description" src="{% static 'images/imglogo.png' %}"></label>
        <input type="file" name="Photo" required="" id="id_Photo" style="display:none" onchange="preview_image(event)">
        <img height="120" width="120" id="output_image"/>

推荐阅读