开发者

save file to virtual directory

Hi I am unsure how to do this, I am using shared hosting. I have a virtual directory at http://www.example.com/images. This directory is actually a folder on the server assets/images whereas my site is at /httpdocs (httpdocs and assets folder are at the same level).

How can I save files to this folder and then access using eg /images/foo.jpg?

httpdocs/

--web.config

--default.aspx

--etc开发者_开发百科

assets/

--images/

----foo.jpg


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


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

Exactly how you save it depends on how the person is uploading it. Are you using a form where someone picks a file and then submits it on a web page? If you are, this link will help you with the saving part.

Good luck. :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜