d
Amit DhamuSoftware Engineer
 

Useful Folder and File Functions in PHP

1 minute read 00000 views
/* 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');