如何在ASP.NET mvc5中上传图像时显示图像 [英] How to display image when it is uploaded in ASP.NET mvc5

查看:122
本文介绍了如何在ASP.NET mvc5中上传图像时显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

上传时我不会显示或预览图片



我尝试过的事情:



I wont to display or preview image when its uploaded

What I have tried:

@Html.Label("Browse File", htmlAttributes: new { @class = "control-label col-md-2" })
                  <div class="col-sm-4">
                      <input type="file" id="FileUpload1" class="form-control" />

                  </div>
                <div class="col-sm-4">
                    @Html.Label("Logo", htmlAttributes: new { @class = "control-label col-md-2" })
                    <img src="@Url.Content("FileUpload1")" alt="Image" />
                </div>

推荐答案

我的问题解决了Thant's

这里我的代码

my problem is solved Thant's
here my code
@Html.Label("Browse File", htmlAttributes: new { @class = "control-label col-md-2" })
                  <div class="col-sm-4">
                      <input type="file" id="FileUpload1" class="form-control"  onchange="document.getElementById('logoImage').src = window.URL.createObjectURL(this.files[0])">

                  </div>
                   <div class="col-sm-4">
                       @Html.Label("Logo Image", htmlAttributes: new { @class = "control-label col-md-2"})
                       <img id="logoImage" src="FileUpload1" alt="Logo Image" width="100" height="100" style="border:1px ;margin-top:20px; margin-left:120px;" />
                       </div>


这篇关于如何在ASP.NET mvc5中上传图像时显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆