I am using for the first time the input type=“file” to get the user select a path on his system where the rest of my code will look to perform some calculations.
After not having found on this forum any answer to my problem I decided to open this thread.
The whole idea of getting the full path from a client’s system will totally be unacceptable by users. If it were possible then any site can get information from the client’s machine. This will never be possible simply due to security reasons. So I guess there is really no way of getting that path.
But if there is some way do let me know.
echo('
<form method="post" action="'.$_SERVER[PHP_SELF].'"> // note: no enctype="multipart/form-data" on this line!
<input type="file" name="dir_to_search" size="50">
<input type="submit" name="submit" value="Search">
</form>
<br /><br />'."\
");
if (isset($_POST['submit']) && ($_POST['submit'] == 'Search')) {
$dir_to_search = $_POST['dir_to_search'];
echo 'post: '.$dir_to_search.'<br />';
}
If I run this page with IE6, this is the result I get:
post: \\\\Dell700\\Doc\\Musica\\music.bmp
For a directory on another local PC.
If I select a file on the same system, I got:
post: D:\\ShareDocs\\Musica\\Global list.wpl
I am not sure if it can help you. Actually all I needed is being able to read all files included within the starting directory (the one choosen by the user) and create a list of them in a txt file. Its only something I wil use locally.
It looks it works here, all I need is to remember to use IE as with Mozilla it does not work…
I search also an anser to this question. An because i have found nothing i have created a javascript that can be usefull.
Here it is.
<form method=“what you want” enctype=“do not use multipart/form-data to avoid transmission of the file contents to the server”>
<input type=“hidden” name=“full_path_real”>
<input name=“full_path_fake” type=“file” onchange=‘document.forms[0].elements[“full_path_real”].value=document.forms[0].elements[“full_path_fake”].value’>
<input value=“Go” type=“submit”>
</form>
Now use $_REQUEST[‘full_path_real’] and forgot $_REQUEST[‘full_path_fake’];
That’s all folks for all javascript able internet clients.