问题
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
This is mainly because I'd like to keep the files uploaded by the user, totally seperate from the web app.
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"))
How would I change this line of code to be able to upload to the subdomain easily?
Cheers.
回答1:
If both domains are on the same server, simply point the site for the subdomain to the /Uploads/Docs
directory as the base directory.
You can then restrict this directory from your www
domain.
Different sites can share the filesystem and this may be a good solution for your problem, without changing any code.
来源:https://stackoverflow.com/questions/4104671/save-website-uploads-in-a-subdomain