lintz
Sep 20th, 2006, 01:08 AM
I've got an option where a user can browse for a file using the code below.
What I want to know is how to get the full path of the file selected?
if ($_POST['submit'] == "") {
?>
<form enctype="multipart/form-data" action="<?php echo($_SERVER['PHP_SELF']) ?>" method="post">
File:<br>
<input type="file" name="file1" size="75"></p>
<p><input type="submit" value="Post" name="submit"></p>
</form>
<?
}
else {
$file = $_FILES['file1']['name'];
//$file = test.txt
//I want $file = C:\test.txt etc...
echo "File to upload is ($file)";
}
Also, is there a way to restrict the type of files that are displayed when the "browse" button is clicked? eg. only .txt or .csv etc...
What I want to know is how to get the full path of the file selected?
if ($_POST['submit'] == "") {
?>
<form enctype="multipart/form-data" action="<?php echo($_SERVER['PHP_SELF']) ?>" method="post">
File:<br>
<input type="file" name="file1" size="75"></p>
<p><input type="submit" value="Post" name="submit"></p>
</form>
<?
}
else {
$file = $_FILES['file1']['name'];
//$file = test.txt
//I want $file = C:\test.txt etc...
echo "File to upload is ($file)";
}
Also, is there a way to restrict the type of files that are displayed when the "browse" button is clicked? eg. only .txt or .csv etc...