保存网站上传的一个子 [英] Save website uploads in a subdomain
问题描述
目前,每当用户上传通过我们的网站的文件时,它被放在一个文件夹中,例如:
Currently whenever a user uploads a file through our website, it gets put in a folder such as:
www.domain.com/Uploads/Docs/filename.doc
不过,我想这个移动到一个子域,如:
However, I'd like to move this to a subdomain such as:
uploads.domain.com/Docs/filename.doc
这主要是因为我想保持用户上传的文件,完全从Web应用程序独立。
This is mainly because I'd like to keep the files uploaded by the user, totally seperate from the web app.
不过,目前我使用ASP.NET 文件上传
控制上传的文件,这样做是这样的:
However, currently I use an ASP.NET FileUpload
control to upload the files, by doing something like:
myFileUpload.SaveAs(Server.MapPath("/Uploads/Docs/filename.doc"))
我要如何改变这一行code,才能够上传至子容易吗?
How would I change this line of code to be able to upload to the subdomain easily?
干杯。
推荐答案
如果这两个域在同一台服务器上,简单地指向该网站的子域名到 /上传/文档
目录作为基本目录。
If both domains are on the same server, simply point the site for the subdomain to the /Uploads/Docs
directory as the base directory.
您可以然后限制从 WWW
域此目录。
You can then restrict this directory from your www
domain.
不同的网站可以共享文件系统,这可能是你的问题很好的解决方案,在不改变任何code。
Different sites can share the filesystem and this may be a good solution for your problem, without changing any code.
这篇关于保存网站上传的一个子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!