Save file to virtual directory

Hi, I'm not sure how to do this, I use shared hosting. I have a virtual directory http://www.example.com/images . This directory is actually a folder on the server / images, while my site is located in / httpdocs (httpdocs and the resource folder are on the same level).

How to save files in this folder and then gain access, for example, /images/foo.jpg?

httpdocs /
--web.config
--default.aspx
--etc

assets/
--images /
---- foo.jpg

+4
source share
2 answers

You can usually save files (using FileStream or other things).
Call Server.MapPath("~/httpdocs") to get the path to disk.

+8
source

The easiest way is to create a virtual directory in IIS Manager so that / images actually point to \ images resources (you said that you already have a virtual directory, so this can already be done). To save things there, you use Server.MapPath ("~ / images"), as mentioned by SLaks. Server.MapPath gives you a physical location, and you can save it the way you normally save the file.

Exactly how you save it depends on how the person loads it. Are you using a form where someone selects a file and then uploads it to a web page? If you are, this link will help you with the saved part.

Good luck. :)

+3
source

Source: https://habr.com/ru/post/1344464/


All Articles