-2

I tried to upload image from my sub domain to main domain, i am getting error like: Is not a valid virtual path. Why?

error:is not a valid virtual path

Amar
  • 19
  • 8
  • 2
    There is always a reason...darn computers –  Oct 19 '16 at 11:17
  • Server.MapPath expect you to pass-in relative path (which is something like "~/customerticket/1234.jpg"), it wont work on absolute url - check out documentation. Also note grabbing fields directly from FormCollection is bad mvc design - you should have strongly-typed model instead. – Ondrej Svejdar Oct 19 '16 at 11:26
  • Thanx Ondrej, what is say, actually my main domain is made on asp.net but my sub domain is made on mvc 4. so, i have to use upload url like http://xyz/myfoldername/demo.jpg then how could i use "~/customerticket/1234.jpg" ? – Amar Oct 19 '16 at 11:34
  • try this http://stackoverflow.com/questions/8309001/virtual-path-in-asp-net – Vishwa Ratna Oct 19 '16 at 11:35

1 Answers1

1

Server.MapPath only works on the same application. If you want to upload your file elsewhere, there are at least 3 ways:

  1. Put it on the directory that original domain could access and just read from there (it is easier if it is the same server);
  2. Upload directly to your another application using web services;
  3. Upload it to another server's FTP/sftp.
Community
  • 1
  • 1