Answer the question
In order to leave comments, you need to log in
Delete files with Ubuntu terminal from PHP?
Unable to delete files in upload folder via terminal:
$output2 = exec('rm -f /usr/share/nginx/html/upload/*.{jpg,png} 2>&1',$output);
Answer the question
In order to leave comments, you need to log in
Why don't you want to delete files using PHP, like this:
function remove_files( $dirname ) {
$type = array( 'jpg', 'jpeg', 'png' );
if ( is_dir($dirname) ) { $dir_handle = opendir( $dirname ); }
if ( !$dir_handle ) { return false; }
while( $file = readdir( $dir_handle ) ) {
$ext = explode( '.', $file );
if( !in_array( end( $ext ), $type ) ) { continue; }
if ( $file != '.' && $file != '..' && !is_dir( $dirname . '/' . $file )) {
unlink( $dirname . '/' . $file );
}
}
closedir($dir_handle);
return true;
}
remove_files( '/usr/share/nginx/html/upload' );
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question