Hi every one,pls am trying to copy the content of my fileupload unto an hidden text box so that users will not have to copy it manually,but it just copies the file name wit exception of the path.I need the path name but in IE9,firefox,opera all i get is the file name without file path pls somebody help.
this is my code

protected void Button1_Click(object sender, EventArgs e)
        string filepath = FileUpload1.PostedFile.FileName;
        hiddentext.text = filepath;


have also tried this

protected void Button1_Click(object sender, EventArgs e)
          string s1 = System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName);
          string s2 = string.Copy(s1);
           hiddentext.text  = s2;

It gives same answer pls help.

Thanks in advance

The file path is going to be the file path on the server where you want to the file to go, not the file path on the local client machine.

Do you have the folder structure setup properly on the server? This will have nothing to do with the browser you are using.

hi...For an security reason you can get the loded file path in fileupload control...

Browsers and html5 have changed so that the real filepath is replaced with 'C:\fakepath' for end user security


Are you trying to get the page to validate something else on th form e.g. a textbox before uploading the file?

If so, you do your validation client side that way you will not lose your file path as the form will not be submitted like this:

'on code behind on page load
btnUpload.attributes.add("onclick", "return ValdateForm()")
<!--On Client Side-->
<script language="javascript" type="text/javascript">
function ValdateForm(){
  var txtTextBox = null;
  if(document.getElementById) {
    txtTextBox = document.getElementById("<%=txtTextBox.clientID%>"); 
  else if(document.all) {
   txtTextBox = document.all["<%=txtTextBox.clientID%>"];
   alert("Fill me in!");
   return false;
  else {
   return true;

If the Textbox has no value the javascript will return a false and stop the button submitting the form (leaving your filepath in place). If there is a value in the textbox, the javascript returns true, the form submits and eveything goes on as normal.