When upgrading a portal, what happens to the existing resonators on it?
I found that upgrading makes the resonator that was there effectively disappear; It doesn't get dropped, it doesn't go back into your inventory. It is no more.
However you can save yourself some trouble by not pressing the deploy button or swipe action. Select the portal, select upgrade portal, scroll through the empty slots for resonators, and on each slot scroll through your resonator inventory exactly specifying the level you want to put in that slot. No need to upgrade over an existing one unless you're actually looking at a portal you didn't just capture (say someone on your faction put down a bunch of L1 resonators) and want to upgrade.
Existing resonator is being replaced with the new one and you don't get the resonator back, so it is lost. That is why you have to choose wisely which resonators you want to upgrade.