Get File Path
Moderator: General Moderators
Get File Path
Hi there
Im trying to get the file path from a browse button so that I can send it to a php class to parse its contents
Currently I have this
<form name="someform" action="test2.php" method="post">
<input type="file" name="FileName" size="chars">
<input type="submit" />
</form>
But all it gives me is the filename itself
How do I get the path of the file?
For example C:\Test.txt rather then just Test.txt?
Thanks
Im trying to get the file path from a browse button so that I can send it to a php class to parse its contents
Currently I have this
<form name="someform" action="test2.php" method="post">
<input type="file" name="FileName" size="chars">
<input type="submit" />
</form>
But all it gives me is the filename itself
How do I get the path of the file?
For example C:\Test.txt rather then just Test.txt?
Thanks
Re: Get File Path
hmmmm
Still only gets the file name...
Still only gets the file name...
Re: Get File Path
Then what's your code?
Re: Get File Path
<!-- The data encoding type, enctype, MUST be specified as below -->
<form enctype="multipart/form-data" action="test2.php" method="POST">
<!-- MAX_FILE_SIZE must precede the file input field -->
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
<!-- Name of input element determines name in $_FILES array -->
Send this file: <input name="attachment" type="file" />
<input type="submit" value="Send File" />
</form>
And my test2.php is
<?php
echo "The other file is ".$_POST['attachment'];
?>
<form enctype="multipart/form-data" action="test2.php" method="POST">
<!-- MAX_FILE_SIZE must precede the file input field -->
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
<!-- Name of input element determines name in $_FILES array -->
Send this file: <input name="attachment" type="file" />
<input type="submit" value="Send File" />
</form>
And my test2.php is
<?php
echo "The other file is ".$_POST['attachment'];
?>
Re: Get File Path
Try that again. Pay attention to the bits that mention the $_FILES array.tasairis wrote:Read.
Re: Get File Path
access the value through JS
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Get File Path
When you upload a file it is placed in a temporary file that will be deleted when the script is done. $_FILES['userfile']['tmp_name'] holds the full path to the temp file. You must use move_uploaded_file() to move the file to the place that you want it. You may use the original name of the file (contained in $_FILES['userfile']['name']) to give the temp file a name -- or name it yourself to whatever you want.
(#10850)
Re: Get File Path
Yeah, thanks guys. Got it working now.
Not the way I originally intended to do it but it works all the same.
Not the way I originally intended to do it but it works all the same.