Download the firmware again & use an ethernet cable to do the firmware upgrade.
DO NOT upgrade firmware over WiFi.
Once the download is finished, extract the file to the root folder of your harddisk. Do not extract it into another folder.
Example:
"C:\"thanks for yr cautionary statement, i was very careful when i upgraded just a few minutes ago.
RT-N12HP B1, using old firmware for 3 months. been reluctant to upgrade since it worked good, no problems.
this morning i decided to go 3.0.0.4.376.2048:
my pc is on wifi.
log in, downloaded firmware on usual download folder, extracted it there.
use firmware update option, it asks u where to update from, select that file in window prompt.
message wait 3 mins.
when done, it asked u to go thru the settings, password, etc.
then, at the point after unifi pw, trying to set internet connection, it kept saying timeout...
nothing worked, all devices no connection!
i sweated!
then i did
REBOOT.message came up, new settings now being applied, 1-2 minutes.
and ... viola, all is good again.
so, not so hard after all, just a few minutes, and need to reboot.

I have tried both of the solutions you provided, but none will works.
still show the same messages that firmware upgrade failure.
my current RT-N12 router firmware is 3.0.0.4.374_430.