Attempt:
Since U is open and connected, U is path connected. then there exists a path $\gamma(t):[0,1]\to U$ between any points $a,b\in U$ such that $\gamma(1)=b$ and $\gamma(0)=a$ Define $h(t)=(f\circ\gamma)(t):\mathbb{R}\to \mathbb{R}^m$
What I want to do:
$h(1)-h(0)=\int_0^1 \frac{d}{dx}f(\gamma(t))dt=\int_0^1Df(\gamma(t))\gamma^\prime(t)dt=0$
then $f(b)=f(a)$ $\forall a,b\in U$ so $f$ is constant. But I don't know that this path is differentiable, so this approach doesn't work.
It reduces to the case $m=1$. Let $a$ in $U$ and let $b=f(a)$. We will prove that $A=\{x\in U:f(x)=b\}$ is non-empty, open and closed in $U$. By definition, $a$ is in $A$ so $A$ is non-empty. Also $A=f^{-1}(\{b\})$ is closed because it is the preimage of a closed set under a continuous function. Finally, if $p$ is in $A$, there exists a positive real number $\epsilon$ such that the open ball $B_\epsilon(p)$ of center $p$ and radius $\epsilon$ is included in $U$. Let $q$ in $B_\epsilon(p)\setminus\{p\}$. Consider the continuous function $g:t\in [0,1]\mapsto f(tq+(1-t)p)\in B_\epsilon(p)$. Then $g$ is differentiable in $(0,1)$ and its derivative is $g'(t)=D_{g(t)}f.(q-p)=0$. So $g$ is constant and in particular $g(0)=f(p)=f(q)=g(1)$. Then $q$ is in $A$ and thus $B_\epsilon(p)\subseteq A$. So $A$ is open. We conclude that $A=U$ because $U$ is connected.