Click here to Skip to main content
15,889,808 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to display the photo through the Path which is saved on the database Like this \\94.19.247.273\C$\\t\q\laptop.com\bb\images\UrunImages\a1\14-09-18-_04-17-00.jpg . I have mothod to convert the path

 public FileContentResult ImagePath(string path)
    {

        string str1 = "C:/";
        string str2 = "//94.19.247.273/C$//";
        string result = path.Replace(str2, str1);

        byte[] imageArray = System.IO.File.ReadAllBytes(result);
        return new FileContentResult(imageArray, "image/png");
    }
I get it from Stackoverflow and on the View like this

  @foreach (var item in Model.ProductPhotoPathList)
                {
                    <li data-thumb="@Url.Action("ImagePath","Home",new { path = item})">
                        <div class="thumb-image"> <img src="@Url.Action("ImagePath","Home",new { path = item})" data-imagezoom="true" class="img-responsive" alt=""> </div>
                    </li>
                }
but here is a problem when page load ImagePath method work successfully but on the page i still get the Path like which is saved on the database \\94.19.247.273\C$\\t\q\laptop.com\bb\images\UrunImages\a1\14-09-18-_04-17-00.jpg, so i can not get changed path on the page.I want to get path like this :C:\t\q\laptop.com\bb\images\UrunImages\a1\14-09-18-_04-17-00.jpg what the problem might be?


What I have tried:

i have this path /Home/ImagePath?path=%2F%2F94.19.247.273%2FC%24%2F%2FBaburtechAnakartImage%2FACER_murtaza%20test1%2F1_ACER_murtaza%20test1_12-09-18-_11-20-02.jpg.

so i want to convert it to /Home/ImagePath?path=C%3A%2FBaburtechAnakartImage%2FACER_murtaza%20test1%2F1_ACER_murtaza%20test1_12-09-18-_11-20-02.jpg.

the method convert it correctly but i can not get it on the page.
Posted
Updated 15-Sep-18 6:41am

1 solution

Well, your web server isn't sending the image. It's sending the link (full path) to the client and the client has to get the image.

The problem is that C$ is an ADMIN SHARE. This is something only users who are administrators on that remote server can get at. It is very unlikely that every client user you're serving pages to is going to be an admin on that remote server.

You have a fundamental design flaw in your architecture.

The image files must be in a location that your users will have access to. That can NOT be in a share that ends with $.
 
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