Xoá ảnh webp trên hosting bằng code PHP
Đuôi file .webp
<?php
// Target folder
$directory = __DIR__ . '/wp-content/uploads';
// Create a RecursiveIterator to recursively go through all folders
$iterator = new RecursiveDirectoryIterator($directory);
// Make the iterator recursive
$recursiveIterator = new RecursiveIteratorIterator($iterator);
// Loop through all files in the directory and its subdirectories
foreach ($recursiveIterator as $file) {
// Check if the file is a .webp file
if (strtolower(pathinfo($file, PATHINFO_EXTENSION)) === 'webp') {
// Attempt to delete the file and check the result
if (unlink($file)) {
echo "Deleted: " . $file . PHP_EOL;
} else {
echo "Failed to delete: " . $file . PHP_EOL;
}
}
}
?>Đuôi file .bk.jpg
Last updated