0

Situation:

I working on image gallery type application where i have two different servers. One that will hold the image files(CDN or File Server can say) only. Another will have the web pages that will access those images.

For example

Site is hosted on http://www.abc.com and Images are uploaded under directory on http://www.imageserver.com/uploads/images/. Assuming I have full access to both of them and also granted read/write permission to the Images directory.

Problem:

When I use FileUpload.SaveAs from my localhost {while development}, it throws an exception saying somthing similar to:

The declared path is not rooted and SaveAs requires rooted path.

Please help. Thanks in Advance

  • Check Jon Skeet answer on a similar post http://stackoverflow.com/questions/1206662/the-saveas-method-is-configured-to-require-a-rooted-path-and-the-path-fp-is-n – Boomer Dec 18 '12 at 10:46
  • shared folder on "image server" could help, or use some tool like xcopy. http://superuser.com/questions/120263/looking-for-a-command-line-tool-to-copy-files-to-remote-computers-similar-to-ps – KoViMa Dec 18 '12 at 10:46
  • @Boomer - That is same server, not cross server. – webnoob Dec 18 '12 at 10:47
  • do you mean this only happen when you save from localhost and doesn't happen if you do the same from live site? – codingbiz Dec 18 '12 at 10:51
  • @codingbiz : Right now i am trying from my dev machine. But my future scope is from One Server to Another. Also currently both domains are deployed on same IIS (Brainpulse Hosting) but later we can separate the hosts. –  Dec 18 '12 at 10:57
  • @KoViMa can't go for xcopy as i am maintaining a db for the same. In case xcopy failed to transfer images. It might result in manual task of moving images. That will be an overkill of time and resources. –  Dec 18 '12 at 10:59

1 Answers1

0

FileUpload.SaveAs cannot be used to save a file to a remote server. It is designed to be used to save files to the "same" web server.

Edit: I would have a script on the remote server and post your image upload form to that.

webnoob
  • 14,765
  • 12
  • 73
  • 149
  • Any control or workaround for the same. As it is required extensively –  Dec 18 '12 at 10:46
  • Yeah thats seems a great work around. But still a confusion here , how to send the image's binary data to that script? –  Dec 18 '12 at 10:48
  • If you just have a form with an image upload box then the data is sent via the `method` attribute i.e `POST` so you will be able to access it via the post data on your remote script. – webnoob Dec 18 '12 at 10:49
  • Right now they are on same network under a shared hosting environment. Both of them are having IP 216.151.xxx.xxx. But in future we might separate those servers –  Dec 18 '12 at 10:50
  • Right Ok, then AFAIK posting to a remote script is your best option. – webnoob Dec 18 '12 at 10:50