PHP Filesystem Functions
Following example shows you some useful functions in filesystem. |
||||||||||||||||||||||||||||||
How to get the total size of a system disk drive in PHP?$totalDiskSize= disk_total_space("C:");echo $totalDiskSize.' Bytes'; echo ($totalDiskSize/1024).' Kb'; echo ($totalDiskSize/(1024*1024)).' MB'; echo ($totalDiskSize/(1024*1024*1024)).' GB'; |
||||||||||||||||||||||||||||||
How to get the free space of a drive in PHP?$free_space=disk_free_space("C:");$freeDsikSpace=diskfreespace("C:"); echo $freeDsikSpace.' Bytes'; echo ($freeDsikSpace/1024).' Kb'; echo ($freeDsikSpace/(1024*1024)).' MB'; echo ($freeDsikSpace/(1024*1024*1024)).' GB'; |
||||||||||||||||||||||||||||||
How to determine whether a file or directory exists using PHP?
|
||||||||||||||||||||||||||||||
Get information about a file in PHP .
|
||||||||||||||||||||||||||||||
How to rename a file or directory in PHP?$old_file_name='C:\\abc.jpg'; if(file_exists($old_file_name)){ |
||||||||||||||||||||||||||||||
How to copy a file in to another location in PHP?$old_file_name='H:\projects\hexa\data\old.txt'; if(file_exists($old_file_name)){ |
||||||||||||||||||||||||||||||
How to delete a folder in PHP?
|
||||||||||||||||||||||||||||||
How to create a folder/directory in PHP
$folder_name='H:\projects\hexa\data'; if(!file_exists($folder_name)){ |
||||||||||||||||||||||||||||||
How to create a simple text file in PHP $fileName='H:\projects\hexa\data\test.txt'; if(!file_exists($fileName)){ if(file_exists($file_name)){ |
||||||||||||||||||||||||||||||
How to read a file in PHP
$fileName='H:\projects\hexa\data\test.txt'; if(file_exists($fileName)){ if(file_exists($fileName)){ |