0

I have created an upload file functionality using <input type="file" name="attachment"/>. I need to know the absolute path of the file attached, for e.g if I browse file from the location D:/MyFolder/Test.text

How can I get this location using VBScript?

Shadow The GPT Wizard
  • 66,030
  • 26
  • 140
  • 208
  • You can't. Modern browsers hide the full path for security reasons. See [this other question](http://stackoverflow.com/q/3489133/447356) as well. – Shadow The GPT Wizard Jun 03 '13 at 10:25
  • you could get it with clientside vbscript (works only in IE) and changing some security settings in IE. is that what you want? – ulluoink Jun 04 '13 at 10:08

1 Answers1

0

According to the specifications of HTML5, a file upload control should not reveal the real local path to the file you have selected, if you manipulate its value string with JavaScript. Instead, the string that is returned by the script, which handles the file information is C:\fakepath.

This requirement is already implemented in Internet Explorer 8 – the real path to the file will be shown only if the page that contains the control is added to the trusted sites collection of the browser. That made sense; essentially the browser is feeding that lame C:\fakepath\ text in.

Reference

You can Just get the name of selected file using this:

var fileName = fileInput.value.replace("C:\\fakepath\\", "");
Ali Sheikhpour
  • 10,475
  • 5
  • 41
  • 82