PHP - Codeigniter - How to delete file with some name -
i have image files name this:
200x200-myimage1.jpg,
300x300-myimage1.jpg,
200x200-myimage2.jpg.
in location uploads/thumbs/thread/
i want delete file contain name of myimage1.jpg.
i have done using glob hsz answered this:
$image_name = "myimage1.jpg"; foreach(glob('./uploads/thumbs/thread/'.$image_name) $rows) { unlink($rows); } but doesn't work.
me?
edit
solved
forget add * before $image_name. become this:
glob('./uploads/thumbs/thread/*'.$image_name)
to filter out files contain myimage1 in name, use glob
foreach (glob("*myimage1*") $filename) { unlink($filename); }
Comments
Post a Comment