<input type = 'file'> IE Gives the full path, FF gives only the file name (or directory lookup)

Possible duplicate:
Can & rsquo; t get the full address when downloading the file

I need a full path. I am trying to provide the functionality of local bookmarks, that is, the user wants to access c:\MyStuff\Myfile.xlson his local PC. How to save / get this value without creating a tutorial help page on how to cut and paste c:\MyStuff\Myfile.xls.

The following code works in IE7. I understand that the problem is related to security, but I don’t need to keep their choice or even use enctype / multiform or even send anything, I just need to choose the path that they chose.

<html>

<head>
  <title></title>
</head>

<body>
<script language="JavaScript" type="text/javascript">
<!--
vic=0;
document.write('<style> .debug {VISIBILITY: visible; POSITION: absolute; TOP: 500px; z-Index:100; }</style>')
<!---->
</script>

Select a file from directory then save the path<br>
<input type="file" id="dir" value="dir" style="width:0px;" >
<input type="button" value="Save Path" onclick="javascript:SavePath();" >

<script language="JavaScript" type="text/javascript">
<!-- works on ie8 not ff.
function SavePath(){
if (document.getElementById('dir').value==''){
  alert('Select a file from the directory');
  return;
}
Path=document.getElementById('dir').value.substring(0,document.getElementById('dir').value.lastIndexOf('\\'));
alert('variable Path='+Path+'\\ ');
}
//-->
</script>
</body>

</html> 
+3
1

.

!

, .

( - : , Windows, \\. /... - .)

/ , ,

. , .

= "JavaScript"

.

javascript:

.

<!--
    ...
<!---->

. ( , -- .)

<!-- works on ie8 not ff.

JavaScript.

+5

Source: https://habr.com/ru/post/1721918/


All Articles