Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Capture the relevant path

Posted on 2013-12-17
12
Medium Priority
?
43 Views
Last Modified: 2015-09-10
Hi,
when running the deployed project in the client machine, I try to catch the full path of the selected file, using these codes

            if (FileUploadControl.HasFile)
            {
                try
                {
                    ...
                    tb_fullname.Text = System.IO.Path.GetFullPath(FileUploadControl.PostedFile.FileName);
                    ...

Open in new window

but I checked that tb_fullname.Text is having the value like
c:\windows\system32\inetsrv\file1.png

not the relevant path in the client machine, in which I'm choosing the file to upload. How to adjust the above?
0
Comment
Question by:HuaMinChen
[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
  • 6
  • 3
  • 2
12 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39725776
It is a security risk for the browser to divulge the location of a file on it's own disk. Only non-standards-compliant browsers (like early editions of IE) transmit this information.
0
 
LVL 11

Author Comment

by:HuaMinChen
ID: 39725784
Is there no way to retrieve that kind of information of the file?
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39725804
Have your user type it into a text box.
0
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
LVL 11

Author Comment

by:HuaMinChen
ID: 39725823
I do try to show the full path of the selected file, in a Textbox.
0
 
LVL 15

Expert Comment

by:Minh Võ Công
ID: 39726873
Do you try tb_fullname.Text = FileUploadControl.FileName;
FileUploadControl.FileName is client path
FileUploadControl.PostedFile.FileName is Server Path
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.fileupload.filename%28v=vs.110%29.aspx
0
 
LVL 11

Author Comment

by:HuaMinChen
ID: 39734420
Hi,
with this line
tb_flext.Text = System.IO.Path.GetExtension(FileUploadControl.FileName);
...

Open in new window

I then rerun the redeployed project, and have selected the file from

c:\shared

that is in the local machine

but I still get this in the Textbox
c:\windows\system32\inetsrv\t315.png
0
 
LVL 11

Author Comment

by:HuaMinChen
ID: 39735285
Any help?
0
 
LVL 15

Accepted Solution

by:
Minh Võ Công earned 375 total points
ID: 39735535
you can try use javascript to get client filename
read the topic
http://javadotnet.in/2012/10/get-file-name-using-javascript-asp-net-fileupload-control/

<script type="text/javascript">
function getFileName() {
var varfile = document.getElementById("FileUploadControl");
document.getElementById("filename").value = varfile.value;
}

<asp:FileUpload ID="FileUploadControl" runat="server" onchange="getFileName()" />
<td>
<input type="text" id="filename" />
</td>
0
 
LVL 11

Author Comment

by:HuaMinChen
ID: 39735561
Sorry, how to show the value of the path in the Textbox?
0
 
LVL 15

Expert Comment

by:Minh Võ Công
ID: 39735585
When you select the file onchage event on getFileName func, in getFileName update content of filename.
0
 
LVL 11

Author Comment

by:HuaMinChen
ID: 39735599
How?
0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

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

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

722 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