Solved

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

Posted on 2008-10-06
5
190 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

717 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