Solved

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

Posted on 2008-10-06
5
186 Views
Last Modified: 2013-12-17
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
Comment
Question by:techques
  • 3
5 Comments
 
LVL 18

Expert Comment

by:David Robitaille
ID: 22651961
try replace te double dot ".." with simple dot "."
strFileDisplay = "./backup/upload/" + strFileName;

0
 
LVL 7

Expert Comment

by:ASPSQLServerCOM
ID: 22653757
0
 
LVL 22

Accepted Solution

by:
prairiedog earned 25 total points
ID: 22661181
Is "Gallery" your application's name? If yes, try this:
strFileDisplay = Request.ApplicationPath + "/backup/upload/" + strFileName;
 
0
 
LVL 7

Assisted Solution

by:ASPSQLServerCOM
ASPSQLServerCOM earned 25 total points
ID: 22661239
use
Path = Server.MapPath(folderName);
0
 
LVL 7

Expert Comment

by:ASPSQLServerCOM
ID: 22698345
hi,any update?
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question