PHP echo file size located in pc -
Ι have somewhere located in pc txt file, let's example c:\users\my_file.txt. there way print size? search it, given:
$filename = 'somefile.txt'; echo $filename . ': ' . filesize($filename) . ' bytes'; but path should give filename variable?
in linux, path separator /. in windows, either \, / or \\.
use front-slashes / on both os never confused.
below can find 3 valid full paths on windows, i.e.:
c:/users/my_file.txt or
c:\\users\\my_file.txt or simply:
c:\users\my_file.txt to filesize can use function filesize
$myfile = "c:\users\my_file.txt" echo filesize($myfile) . "bytes"; if file on same dir php script can use relative path:
$myfile = "my_file.txt" echo filesize($myfile) . "bytes"; if file one dir below can use relative path.
$myfile = "../my_file.txt" echo filesize($myfile) . "bytes"; another relative path example, time 1 dir up:
$myfile = "./newdir/my_file.txt" echo filesize($myfile) . "bytes";
Comments
Post a Comment