I have an admin panel from where I am uploading files to ~/uploads
and from Home site I want to access these images path.I have read about Server.mapPath()
but it is giving me the root path of the current running application. I want to store the absolute path of the images in db so that I can access them from home site. have read about storing images in db in the form of base 64 but I want to use the file system. Sorry for incorrect english..
path = Path.Combine(
System.IO.Path.GetPathRoot(System.Web.Hosting.HostingEnvironment.MapPath("~/uploads")),
image.FileName);
image.SaveAs(path);
different scenario different way. If you are using local IIS to host your applications,
Path.Combine(System.IO.Path.GetPathRoot(System.Web.Hosting.HostingEnvironment.MapPath("~/uploads")), image.FileName);
<img src='<%=ResolveClientUrl("~/uploads/xxx.jpg")' />
to show the image, if you are using MVC, then no need to use ResolveClientUrl to deal with "~" if you are using cloud based app, like azure app, then just use azure blob to save your file, also amazon S3 is great and easy to use
if these two apps are hosted on different server, but same subnet, use then you can use path like "\\192.168.1.1\\uploads" as physical location for the virtual directory, make sure you have the correct credential to access the network driver
if these two apps are not on server and even can not access to each other and any other 3rd server, then you can use dropbox to do the synchronization, set up dropbox on both server, map the virtual directory to an fold under dropbox, the image will be synced to front app right after you saved the file on admin
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.