The MD5 and SHA1 hash algorithms use the Merkle–Damgård construction to deal with long inputs. The term 'message' is used to refer to any electronic file input for which a hash function generates an alphanumeric code of a fixed number of characters. The Merkle–Damgård construction breaks a message into smaller blocks of the same size and generates a hash function for each. The first small or compression hash function is added to a fixed value, and then each successive compression hash function is added to the next. A padding value is added to the last block so all of the blocks are the same size. The padding value is a series of 0's and 1's. The hash function takes an input of any size and generates an output hash value of a fixed length. The unique digital fingerprint or the hash value is known as the message digest.
The basis of the construction is that if each compression hash function is collision resistant (it will not give the same value for two different inputs), then the hash function will be collision resistant. It is the Merkle-Damgård construction that allows hash functions to deal with message inputs of variable lengths.
See the below diagram of the Merkle-Damgard construction.
Mridul Nandi, Characterizing Padding Rules of MD Hash Functions Preserving Collision Security, National Institute of Standards and Technology, in Colin Boyd, Juan González Nieto J. (eds.) Information Security and Privacy (2009), available at: https://eprint.iacr.org/2009/325.pdf