EDIT(8/6/2017): I just found I don't need to keep updating upper if I know where it will land (when i == num/i, it doesn't matter if i< or <= sqrt(num) as explained in comment), and it reduces run time from 1055ms to 3ms, well...

@MapleLeaf2012 Thanks for pointing out, i didn't notice that before. Emm... so I looked into it, and I found it only affects the perfect squares, i.e. 4, 9, 16..., etc. And according to wikipedia, all the perfect numbers within the input range of problem description(0 ~ 100,000,000. (1e8)) are not perfect sqaures, actually there are only 5 numbers {6, 28, 496, 8128, 33550336}, (that's why i put 'normal' solution in the title), so i guess it explains that we don't need to check whether i == num / i only for solving this problem.
But it's just a single line and I think in the aspect of accuration, it would be better to have that in the code.