hi i am using this exec("du -sh -S ".$fileFlv.""); command in php to get size of a file all the things works fine but the problem at my end is i want only the size but it dispalys the size as well as name of the file
+1 - a lot more efficient than spawning a new process!
Paul Dixon
2009-08-28 15:46:01
Note: don't forget that php caches the filesize() result.
Zed
2009-08-28 15:48:41
+1
A:
If you just want the size or other properties of a single file, you can use stat instead of du. (There's probably built-in PHP functionality for this too.) The -c option lets you customize the output format. Here's the size in bytes.
stat -c %s myfile.txt
If you really want du (to get total size of directories), you can use cut to munge the output.
du -sh -S mydir | cut -f1
Or just capture the output to a string in PHP and strip the filename there.
Andrew Janke
2009-08-28 15:48:45