• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 198
  • Last Modified:

How to locate the path of an image in a host?

protected System.Web.UI.HtmlControls.HtmlInputFile fileAttachment;
protected string strFileName, strFile;

strFileName = this.fileAttachment.PostedFile.FileName;
strFileName = Path.GetFileName(strFileName);
strFile = strBaseDirectory + strFileName;
strFileDisplay = "../backup/upload/" + strFileName;
fileAttachment.PostedFile.SaveAs(strFile);

The correct path is
http://localhost/Gallery/backup/upload/tty.jpg

However, when I see the strFileDisplay, it is
http://localhost/backup/upload/tty.jpg

Gallery is the virtual directory under IIS's default website.

How should I fix it?
0
techques
Asked:
techques
  • 3
2 Solutions
 
David RobitailleAnalyst ProgrammerCommented:
try replace te double dot ".." with simple dot "."
strFileDisplay = "./backup/upload/" + strFileName;

0
 
ASPSQLServerCOMCommented:
0
 
prairiedogCommented:
Is "Gallery" your application's name? If yes, try this:
strFileDisplay = Request.ApplicationPath + "/backup/upload/" + strFileName;
 
0
 
ASPSQLServerCOMCommented:
use
Path = Server.MapPath(folderName);
0
 
ASPSQLServerCOMCommented:
hi,any update?
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now