Solved

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

Posted on 2008-10-06
5
183 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
Comment Utility
try replace te double dot ".." with simple dot "."
strFileDisplay = "./backup/upload/" + strFileName;

0
 
LVL 7

Expert Comment

by:ASPSQLServerCOM
Comment Utility
0
 
LVL 22

Accepted Solution

by:
prairiedog earned 25 total points
Comment Utility
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
Comment Utility
use
Path = Server.MapPath(folderName);
0
 
LVL 7

Expert Comment

by:ASPSQLServerCOM
Comment Utility
hi,any update?
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

744 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now