In the future, use a fermentation vessel large enough to contain the foam. Many people use 2 gallon food-safe plastic buckets for making 1 gallon batches, or a 7.9 gallon bucket for making 5 gallon batches. They're inexpensive and available at almost any homebrew store.
In addition to saving your floors and not exposing your lovely new mead to infection when you blow out the airlock, adding fruit, dry hopping, etc is much easier when you can reach inside the fermenter instead of being restricted by the tiny hole of a carboy.
It’s also helpful for the process of aging your meads - whenever you rack into a new fermentation vessel, you'll leave behind the dead yeast and whatever liquid your autosiphon can't pick up. This means that if you start with a gallon, when you rack it into an aging carboy, you'll be left with less volume than would fill the carboy, meaning more headspace while aging and more chance of oxidation. Fermenting a little more than your target volume to start with will prevent this from being a problem, and to do that, you need a larger fermentation vessel.
If for some reason you absolutely cannot purchase fermenters of sufficient size, you can use a blowoff tube, but this is much less reliable and can still create a huge mess during a vigorous fermentation if it gets clogged with, for instance, fruit or tea leaves.
To make a blowoff tube, run a length of tubing from the bung or the carboy's neck into a glass half-filled with sanitizer. Submerge the end in the sanitizer. This functions as an airlock that can - usually - safely vent the foam from your mead.
Be wary, however, that very strong fermentations, or fermentations that contain a lot of large solid particles may still be able to clog the blowoff tube.