HomePHP Page 13 - File And Directory Manipulation In PHP (part 2)
Disk Full - PHP
Now that you know the basics of reading and writing files, this second segment of our tutorial on the PHP filesystem API takes you into deeper waters, showing you how to copy, delete and rename files; scan directories; work with uploaded files over HTTP; perform pattern matches on file names; and read and write to processes instead of files.
And that's about all I have. Over the course of the last few pages, I took you ever deeper into the waters of PHP's filesystem API, demonstrating a number of its more arcane features and functions. I showed you how to strip out program code from a file while reading it, how to parse comma-separated data from a file into PHP structures, and how to read configuration variables into a PHP associative array.
Next, I introduced you to PHP's file copy, move and delete functions, and demonstrated them in the context of a file upload application. I also showed you how to read and display the contents of a directory, and how to recursively iterate through a series of nested directories. Finally, I wrapped things up with a brief look at how to obtain disk usage reports for a mount point or partition, and explained how you could read data from processes just as you do with files.
While this tutorial did cover many of the common uses of PHP's file and directory manipulation functions, it is by no means exhaustive. There are many more things you can do with PHP's file functions - and you can get some great ideas (and learn a number of interesting things as well) by perusing the PHP manual pages for these functions, at the links below: