Simple, specify the path to the file (must be root path).
File:
$delfile = @unlink("/home/domain/www/directory/filename.jpg");
if (!$delfile) { echo "Failed to delete file"; }
Directory:
$deldir = @unlink("/home/domain/www/directory");
if (!$deldir) { echo "Failed to delete Directory"; }
Keep in mind, you can not delete (unlink) a directory if there are files located in this directory.