shanmugavel-php
shanmugavel-php

Reputation: 410

To delete the directory(folder) in the linux server using php code?

I want to delete the folder which in the linux server using php ??

Scenario::

When user uploads images , A new folder is created based on his name...when i delete the user account,his named folder should be deleted..

Upvotes: 1

Views: 1111

Answers (1)

Artefact2
Artefact2

Reputation: 7634

Use unlink and rmdir. Calling unlink($file) will delete the file whose filename is $file, however this is non recursive (it only deletes one file at a time, and won't delete a directory if it is not empty).

There are tons and tons of examples that will recursively delete a directory here : https://www.php.net/unlink

Upvotes: 1

Related Questions