Skip to content
Snippets

Snippet Library

Practical pure PHP patterns that are easy to study, adapt and use.

Code

Delete a File

Deletes one existing file only after realpath() confirms it is a file under an approved base directory.

Open Snippet
Code

Copy a File

Copies one file from an approved source directory to an approved destination directory without overwriting existing files unless explicitly allowed.

Open Snippet
Code

Rename or Move a File

Renames or moves a file inside an approved base directory after checking the source file, destination directory, overwrite rule, and path boundaries.

Open Snippet