How can i get Full path of uploaded file in php. As i uploaded a xml file and clicked on submit button full path of uploaded file will be shown on screen.
HTML
<form action="index.php" method="post" enctype="multipart/form-data">
File: <input type="file" name="fileToUpload" id="fileToUpload">
<input type="submit" name="sub" value="Submit">
</form>
PHP
if(isset($_POST['sub']))
{
$file = $_FILES["fileToUpload"]["name"];
$filename = pathinfo($file);
$st_name = $filename['filename'];
$dir= $filename['dirname']; //directory name
echo $dir;
}
Here as i click on submit button output should be like this...
**D://new/folder/file.xml**
Try code below:
$uploads_dir = 'D://new/folder';
$tmp_name = $_FILES["fileToUpload"]["tmp_name"];
$name = basename($_FILES["fileToUpload"]["name"]);
$path = $uploads_dir . DIRECTORY_SEPARATOR . $name;
move_uploaded_file($tmp_name, $path);
echo $path;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.