Amit Dhamu

Software Engineer

Useful Folder and File Functions in PHP

/* Create File */
fopen('new-file.txt', 'w');

/* Create Directory */
mkdir('path/to/new/folder');

/* Check If Directory Exists */
if (is_dir('path/to/folder')) {
    // Directory exists
}

/* Delete Directory  */
rmdir('path/to/folder');

/* Delete File */
unlink('path/to/file');

/* Move File */
rename('old_path/image.jpg', 'new_path/image.jpg');

 file / directory

Toggle Text FunctionDouble Click Event

Show Comments