Tools, FAQ, Tutorials:
Retrieving Directory Name from File Path Name in PHP
How To Get the Directory Name out of a File Path Name in PHP?
✍: FYIcenter.com
If you have the full path name of a file, and want to get the directory name portion of the path name, you can use the dirname() function. It breaks the full path name at the last directory path delimiter (/) or (\), and returns the first portion as the directory name. Here is a PHP script example on how to use dirname():
<?php
$pathName = "/temp/download/todo.txt";
$dirName = dirname($pathName);
print("File full path name: $pathName\n");
print("File directory name: $dirName\n");
print("\n");
?>
This script will print:
File full path name: /temp/download/todo.txt File directory name: /temp/download
⇒ Splitting a File Path Name into Parts in PHP
⇐ Reading Directory Entries in PHP
2016-11-20, ∼3232🔥, 0💬
Popular Posts:
How To Loop through an Array without Using "foreach" in PHP? PHP offers the following functions to a...
How to use urllib.parse.urlencode() function to encode HTTP POST data? My form data has special char...
dev.FYIcenter.com is a Website for software developer looking for software development technologies,...
How To Break a File Path Name into Parts in PHP? If you have a file name, and want to get different ...
How To Move Uploaded Files To Permanent Directory in PHP? PHP stores uploaded files in a temporary d...