Search code examples
phpdirectorydelete-fileunlink

PHP unlink command deleting multiple files


I am calling the php unlink() function on a directory (user-images/1/p/) containing the following files:

1.jpg
1-s.jpg
1big.jpg
2.jpg
2-s.jpg
2big.jpg

The actual call itself is as follows:

unlink('user-images/1/p/1big.jpg');

Instead of just deleting 1big.jpg, it deletes all files with a 1 in them (1big.jpg, 1-s.jpg, 1.jpg). I've researched this quite a bit and can't seem to find anyone posting with a similar issue.

EDIT: below is the full script, not much there really, don't see how anything could be affected. I've never seen this before either :(

<?PHP
unlink('user-images/1/p/1.jpg');
unlink('user-images/1/p/1-s.jpg');
$uid = '1';
$fileName = '467';
$image = '/friskyfriends/user-images/1/p/1-big.jpg';
$width = 320;
$height = 320;
buildPics();
//buildPics($uid,$fileName,$image,$width,$height);
?>

Solution

  • When running the php file with only the unlink code in it, it worked fine. I traced through the rest of my includes (took forever :( ) and found some issues in coding before. Still not sure why that affected a static unlink() call. That said, it was an issue elsewhere in the code which has been resolved. I appreciate the time and effort everyone put forth to help me troubleshoot this issue...