Click here to Skip to main content
15,905,323 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have my website C:\inetpub\wwwroot\website. in my website i upload the image using c# to c:\inetpub\wwwroot\Uploadimages\. i have successfully upload image in this folder. but i could not get image from this path to display image in website. how to display image from outside the root folder. please any one help me with that.?
Posted
Comments
Sajith Dilhan 4-Mar-15 3:22am    
<img src="<%=yourpath%>/Images/imgxx.png" />

you can specify the path in web.config file.
Member 10705961 4-Mar-15 3:35am    
i have to give path in c#. how to do outside the project folder path in c#.?
[no name] 4-Mar-15 3:28am    
C:\inetpub\wwwroot\websitename\Uploadimages\img.jpg ? this is ur path.u can easily retrieve the image.do u got any error?
Member 10705961 4-Mar-15 3:34am    
can you please elaborate with some code. i already using with web.config file, but it did not work
Sajith Dilhan 4-Mar-15 3:43am    
put the path in web config
< configuration>
....
< appsettings>
< add key="ImagePath" value="C:\inetpub\wwwroot\websitename\Uploadimages">


....
< /configuration> ;

then read it from C# code
string path= WebConfigurationManager.AppSettings["ImagePath"]

1 solution

ASP.NET
<form id="form1"  runat="server">
<asp:image id="Image1" runat="server" imageurl="~/Uploadimages/imag.jpg" />
<%--'~' it's denoting the root path--%>
</form>
 
Share this answer
 
v2
Comments
Member 10705961 4-Mar-15 3:49am    
the path is dynamic. so i want to give image path using c#. the path change based on user selection
Sajith Dilhan 4-Mar-15 3:51am    
then you have to bind the path in page load event dynamically.
get the path into a variable based on the user selection.
then bind to image
<img src="<%=yourpath%>/Images/imgxx.png" />
Member 10705961 4-Mar-15 3:53am    
can you please give code in c#
[no name] 4-Mar-15 4:02am    
try this :
http://forums.asp.net/t/1892399.aspx?How+can+I+change+and+image+dynamically+in+my+controller+code+C+and+client+side+

http://stackoverflow.com/questions/14517392/change-image-path-for-upload-control-dynamically
Member 13161813 30-Nov-17 0:13am    
Dear sir/mam
please help me given below question .
Display Images saved in folder outside the Website Root directory With using DataTable in GridView ASP.Net

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