'. $filename .' has been deleted'; } else { echo 'File cannot be deleted!'; } $file = 'filetorename.txt'; $rand = rand(10000,99999); if(@rename($file,$rand.'txt')){ echo 'File has been renamed successfully to ' . $rand; } else { echo 'File cannot be renamed!'; } ?>