Answers for "delete file php from directory php"

PHP
10

php remove file

if(file_exists($file)) {
	unlink($file);
}
Posted by: Guest on January-13-2020
0

get delete folder in php

$dirPath = "../images/productimages/$productid";
	if (is_dir($dirPath)) {
		shell_exec("rm -rf " . $dirPath);
		rrmdir($dirPath);
	}

// call function

function rrmdir($src) {
    $dir = opendir($src);
    while(false !== ( $file = readdir($dir)) ) {
        if (( $file != '.' ) && ( $file != '..' )) {
            $full = $src . '/' . $file;
            if ( is_dir($full) ) {
                rrmdir($full);
            }
            else {
                unlink($full);
            }
        }
    }
    closedir($dir);
    rmdir($src);
}
Posted by: Guest on June-15-2021

Code answers related to "delete file php from directory php"

Browse Popular Code Answers by Language