Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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>
Posted
Updated 15-Sep-18 4:36am

1 solution

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>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900