Can I charge my MacBook Pro from an older iMac?
There's no other way of charging a 2012 MacBook Pro than through the MagSafe power port. If that has stopped functioning, you cannot charge the laptop as usual.
Your options are primarily:

getting the MagSafe power port repaired
taking out the battery and charging it externally and put it back
take out the hard drive or SSD (depending on model) and transfer data externally

To recover the files I would prefer the last option, taking out the drive. It is an ordinary SATA interface, so you should be able to buy a cheap USB-to-SATA interface at most computer stores, that would enable you to transfer the data to another computer.