PHP/web programming get full local path of a file
Discussion
Is there a way to see the local path of a file that a user is trying to upload?
I'm wanting to know this because im wirting a script to generate a INI file which includes absolute paths to files on a system.
So for example if i chose to upload a file off my computer "C:\program files\testfolder\testdatabase.mdb" then i can locate that using the file browser on the page and when i submit i can use that path as a variable to enter into the INI in which im creating.
I've looked in just PHP but there isn't a way but anyone any ideas of how i could transfer the path to another variable with javascript?
Regards
Liam
I'm wanting to know this because im wirting a script to generate a INI file which includes absolute paths to files on a system.
So for example if i chose to upload a file off my computer "C:\program files\testfolder\testdatabase.mdb" then i can locate that using the file browser on the page and when i submit i can use that path as a variable to enter into the INI in which im creating.
I've looked in just PHP but there isn't a way but anyone any ideas of how i could transfer the path to another variable with javascript?
Regards
Liam
I've once uploaded my stuff to a recruitment site, and I was astonished to find the full path from my machine as the (online-)filename afterwards, i.e. /home/bodo/cv.pdf
I wonder if it just became buggered by the slashes of the Unix notation, as it possibly awaited a backslash to separate the actual file name.
I wonder if it just became buggered by the slashes of the Unix notation, as it possibly awaited a backslash to separate the actual file name.
TangoAlpha said:
Does this page help?
Unfortunatly PHP can't return the entire path of client machine it's just shows the filename it self
GreenV8S said:
If you're willing to rely on client-side script you could read the file name from the input field and return it separately, like this.
seems like this is the only way to go at the moment. One good this is that javascript has to be enabled for the actual application that im writing the INI generator for anyway so should work as all are running IE
Bodo said:
I've once uploaded my stuff to a recruitment site, and I was astonished to find the full path from my machine as the (online-)filename afterwards, i.e. /home/bodo/cv.pdf
I wonder if it just became buggered by the slashes of the Unix notation, as it possibly awaited a backslash to separate the actual file name.
I wonder if it just became buggered by the slashes of the Unix notation, as it possibly awaited a backslash to separate the actual file name.
Sound like a bug to me mate it should see the file uploaded rather than the patch to be honest as ytou can see im trying to get that bug but no one knows how lol
Thanks
Liam
Try this:
<?php
Header("Content-type: text/html"
;
echo "<html> <body> ";
if(isset($_POST['action']))
{
echo $_POST['clientfile'];
}
else
{
echo "<form name='fileform' action='test.php' method=post> ";
echo "<input type='file' name='browsefile' size=50> ";
echo "<input type='hidden' name='action' value=1> ";
echo "<input type='hidden' name='clientfile'> ";
echo "<input type='submit' name='Upload file' onclick='fileform.clientfile.value=fileform.browsefile.value'> ";
echo "</form> ";
}
echo "</body> </html> ";
?>
<?php
Header("Content-type: text/html"
; echo "<html> <body> ";
if(isset($_POST['action']))
{
echo $_POST['clientfile'];
}
else
{
echo "<form name='fileform' action='test.php' method=post> ";
echo "<input type='file' name='browsefile' size=50> ";
echo "<input type='hidden' name='action' value=1> ";
echo "<input type='hidden' name='clientfile'> ";
echo "<input type='submit' name='Upload file' onclick='fileform.clientfile.value=fileform.browsefile.value'> ";
echo "</form> ";
}
echo "</body> </html> ";
?>
Another try to get it formatted correctly...
<?php
Header("Content-type: text/html "
;
echo "<html> <body> ";
if(isset($_POST['action']))
{
echo $_POST['clientfile'];
}
else
{
echo "<form name='fileform' action='test.php' method=post> ";
echo "<input type='file' name='browsefile' size=50> ";
echo "<input type='hidden' name='action' value=1> ";
echo "<input type='hidden' name='clientfile'> ";
echo "<input type='submit' name='Upload file' onclick='fileform.clientfile.value=fileform.browsefile.value'> ";
echo "</form> ";
}
echo "</body> </html> ";
?>
<?php
Header("Content-type: text/html "
; echo "<html> <body> ";
if(isset($_POST['action']))
{
echo $_POST['clientfile'];
}
else
{
echo "<form name='fileform' action='test.php' method=post> ";
echo "<input type='file' name='browsefile' size=50> ";
echo "<input type='hidden' name='action' value=1> ";
echo "<input type='hidden' name='clientfile'> ";
echo "<input type='submit' name='Upload file' onclick='fileform.clientfile.value=fileform.browsefile.value'> ";
echo "</form> ";
}
echo "</body> </html> ";
?>
Gassing Station | Computers, Gadgets & Stuff | Top of Page | What's New | My Stuff



