By the extended Euclidean algorithm there exist polynomials a and b with af + bg = 1. Multiply this relation by h:
Since f | afh and f | bgh, it follows that f | h.