skip to Main Content

enter image description here

HTML

<h3>Single Upload</h3>
<form method="post" enctype="multipart/form-data">
    File <input type="file" name="file" />
    <br />
    <input type="button" value="Upload" onclick="return SaveExit()" />
</form>
<img src="C:/Users/Gigabyte/source/repos/ReimbursementSystem/ReimbursementSystemAPI/wwwroot/Images/biomimikrifix1.png" width="100" height="200" alt="3"  />

I want to simply show the image from the other project with the path but it doesn’t work. is there a way to simply show it from another project?

2

Answers


  1. You can use this code

    <img src="/Images/biomimikrifix1.png" width="100" height="200" alt="3" class="detailImage"  />
    
    Login or Signup to reply.
  2. In ASP.Net Core MVC you are not allowed to load local resource file rather than wwwroot/images folder by default. But if you want to use a different location then you can simply add this middleware to your startup.cs

    Startup.cs

    app.UseStaticFiles();
            app.UseStaticFiles(new StaticFileOptions
            {
                FileProvider = new PhysicalFileProvider(
                Path.Combine(@"C:UsersGigabytesourcereposReimbursementSystemReimbursementSystemAPIwwwroot", "images")),
                RequestPath = "/images"
            });
    

    cshtml

    <img src="/Images/biomimikrifix1.png" width="100" height="200" alt="3"/>
    

    Hope this will solve your issue.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search