显示默认图像,直到图像上传到图像持有人
Display default image until image is uploaded in the image holder
我想要一个默认的图像是可见的图像持有人,直到用户没有上传任何图像。这样,当打印出页面时,就可以看到一个演示用户图像。怎么做呢?
//Html Part
<div class="form-group uploader"> <label class="coole">Upload Child's Image:</label>
<input name="fileToUpload" type="file" id="fileToUpload" /><br />
<div name="image-holder" id="image-holder"> </div>
//Js Part
<script>
$("#fileToUpload").on('change', function () {
if (typeof (FileReader) != "undefined") {
var image_holder = $("#image-holder");
image_holder.empty();
var reader = new FileReader();
reader.onload = function (e) {
$("<img />", {
"src": e.target.result,
"class": "thumb-image",
"width":"113px",
"height":"151px"
}).appendTo(image_holder);
}
image_holder.show();
reader.readAsDataURL($(this)[0].files[0]);
} else {
alert("This browser does not support FileReader.");
}
});
</script>
尝试:
<div class="form-group uploader"> <label class="coole">Upload Child's Image:</label>
<input name="fileToUpload" type="file" id="fileToUpload" /><br />
<div name="image-holder" id="image-holder"><img src='path-to-placeholder-img" class="placeholder"/> </div>
//Js Part
<script>
$('#image_holder').show();
$("#fileToUpload").on('change', function () {
if (typeof (FileReader) != "undefined") {
var image_holder = $("#image-holder");
image_holder.empty();
var reader = new FileReader();
reader.onload = function (e) {
$("<img />", {
"src": e.target.result,
"class": "thumb-image",
"width":"113px",
"height":"151px"
}).appendTo(image_holder);
$('.placeholder').hide();
}
reader.readAsDataURL($(this)[0].files[0]);
} else {
alert("This browser does not support FileReader.");
}
});
</script>
相关文章:
- 如何使用url加载程序在webpack中导入多个图像
- nodejs-expressjs上传图像并显示它们
- 使用JSP从服务器检索和显示图像
- 角度:在ng重复上切换图像
- 画廊图像未显示
- Phonegap-(安卓/iphone)多个图像的图像库出现问题
- Javascript排序的图像弹出窗口..可以't单独弹出
- 画布数据到图像
- Windows8应用程序(html&Javascript):从图片库(除了文件选择器)显示图像的另一种方式
- 使图像在单击时展开到不大于浏览器
- Html页面上的多个Base64图像和平滑加载
- UIAutomation放大图像
- 使用javascript在Flash中加载外部图像
- 可以在这里为背景图像设置滤镜吗
- 当图像转换为本地存储的DataURL时,EXIF被删除
- 使用 js 将背景图像设置为 HTML
- Javascript将图像src更改为淡入淡出
- 无法在本地计算机中将画布另存为图像
- 压缩phonegap中ios的图像插件
- 显示默认图像,直到图像上传到图像持有人