[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 197
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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