FileImporter is an extension for MediaWiki that allows to transfer files from any Wikimedia wiki to Wikimedia Commons, including all history, authorship, and attribution information. All revisions of the file are transfered, as well as the history of all edits made to the file description page. The extension also migrates the contents of the file description page (e.g. headlines, templates, and links) to match Wikimedia Commons' expectations.
How to install the extension: https://www.mediawiki.org/wiki/Extension:FileImporter