Click to See Complete Forum and Search --> : How to get the path of a file in a text box


doglin
October 27th, 2005, 12:30 PM
Hi All:
I have a question. Suppose you want to get the full path of a file in the text box on your web page, like (file://C:/file.rss) but you don't want to use file upload, you just want the full URL of the file. how would you go about that. I mean, you could use text box and type it in, however, is there a way, such that the use can click on the file icon, and the full path just appears in the text box and yet it is not uploading the whole file?

Please let me know.


Many thanks

HanneSThEGreaT
November 1st, 2005, 09:22 AM
You can use the File object of the FileSystemObject (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/sgworkingwithfiles.asp) to retrieve all the information on files

m3rlinez
November 10th, 2005, 08:50 AM
Is this what you want?


<html>
<head>
<title>File path</title>
</head>
<script type="text/javascript">
function showFilePath()
{
var oFile = document.getElementById("file1");
var oLabel = document.getElementById("lblResult");
oLabel.innerHTML = "<b>You selected:</b><br>" + oFile.value;
}
</script>
<body>
<form name="frmTest" id="frmTest">
<input name="file1" id="file1" type="file" title="Click browse to select file"><br>
<input name="btnShow" id="btnShow" type="button"
title="Click to show the file path" onclick="showFilePath()"
value="Click to show file path"><br>
<span id="lblResult" name="lblResult"></span>
</form>
</body>
</html>


With the help of JavaScript you can get the value of file element.