0

I am using RadUpload control of telerik. I have added Rad upload on page and one asp Text box. what I want to do is OnClientFileSelected event selected file path get added in asp Text box at client side. I did tried following ways but i got only file name i.e. test.text or test.doc. I do want to add entire path in asp text box like "C:\folder1\folder2\test1.txt". How should i do this.

function fileSelected(radUpload, eventArgs)
 { 
   var input = eventArgs.get_fileInputField().value;
   document.getElementById("<%= txtPath.ClientID %>").value=input;
 }

Thanks In Advance

Access Denied
  • 886
  • 1
  • 13
  • 24
  • possible duplicate of [Get full path of a file with FileUpload Control](http://stackoverflow.com/questions/1130560/get-full-path-of-a-file-with-fileupload-control) – NotMe Nov 22 '10 at 15:36
  • For numerous security reasons you cannot get the full client path of the file for upload. now, depending on version of the browser, older browsers might put that path in. Ultimately the world has felt that this information is too dangerous and of little to no value to the server. – NotMe Nov 22 '10 at 15:37
  • @Chris, you mean little or no value to the Client. – Chase Florell Nov 27 '10 at 07:39
  • @rockinthesixstring: No, I meant the full path of where the file came from is of little value to the server. All it should care about is the file itself. Where it lived on the client machine should be of no use legitimate use. BTW, I upvoted you.. – NotMe Nov 29 '10 at 17:18
  • ah I see. I thought you meant that the file path on the server is of no value to the client machine. – Chase Florell Nov 29 '10 at 17:33

1 Answers1

2

You cannot do it client side without a little extra help since the client has next to no information about the server. Try setting a hidden field from the server side to store the file path.

 HiddenField1.Value = HttpContext.Current.Server.MapPath("~/my_upload_directory/")

Then on the client side, you just concatonate the HiddenField1.value and the txtPath.value

var fullPath = document.getElementById("<%= HiddenField1.ClientID %>").value + document.getElementById("<%= txtPath.ClientID %>").value;
Chase Florell
  • 46,378
  • 57
  • 186
  • 376
  • Chris is is correct it depend up on the version of browser. IE8 gives me full path but Firefox does not. Thanks for your help – Access Denied Jan 28 '11 at 07:27