javascript - 如何覆盖徽标
问题描述
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"/>
解决方案
尝试
<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"/>
推荐阅读
- git - Git 应该忽略一个 conf 文件,但它不应该在 .gitignore 中
- coldfusion - 如何增加lucee中输入的大小
- ibm-watson - 安装节点红色托盘失败?
- python - Python:带有CSV和Tensorflow的ValueError(CSV行有不同数量的字段)
- machine-learning - 使用带有标签概率总和的 fasttext 的多标签分类不一定等于零
- android - Android 架构组件:我应该将身份验证令牌保存在哪里?ViewModel 还是 SharedPreferences?
- git - 根据提交消息提取多个提交的 Git diff
- azure-devops - 无法从 Azure Devops 获取内部 Gitlab 的数据(获取 Git 获取失败,退出代码:128)
- typo3 - TYPO3:带有 EXT:news 的 OpenGraph 图像大小
- c# - 用 Plinq 替换 Task.WhenAll