2

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.

Curtis
  • 101,612
  • 66
  • 270
  • 352

1 Answers1

0

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.

Oded
  • 489,969
  • 99
  • 883
  • 1,009
  • Thanks for your response, however I think this defeats the reason I want to host uploaded files on a subdomain. I wish to keep the files away from the app, so that the app is standalone, and can be updated, moved around, without having an affect on the uploaded files. Therefore, storing it in the Uploads folder, and pointing the subdomain to it has no use at all. If anything, I'd need the reverse of this process. Cheers – Curtis Nov 05 '10 at 10:07
  • And what if they are on different servers? – Ankur-m Mar 14 '13 at 06:09
  • @Ankur-m - not as easy. You would need a back-channel between the two servers. Some way for them to "talk" to each other and transfer files. You would initiate the transfer after upload. – Oded Mar 14 '13 at 08:44
  • I guess one way is to create a webservice on the destination website to accept files and then save them in required directory. But for some reason that option is not feasible for me. It seems cross domain uploads are also possible now. I just got this link and am reading more about it. Hope they may be of some help (even in my case) - http://stackoverflow.com/questions/6718664/is-it-possible-to-perform-an-asynchronous-cross-domain-file-upload – Ankur-m Mar 14 '13 at 09:19