A characterization of functions from $\mathbb R^n$ to $\mathbb R^m$ which are continuous

Suppose $f$ has your property but is discontinuous at $x=a$. Now for each $\delta > 0$, $f([a-\delta, a+\delta])$ is a connected compact set, and thus is an interval containing $f(a)$. Moreover since $f$ is discontinuous at $x=a$ there must be some $c \ne f(a)$ such that $f([a-\delta,a+\delta])$ contains both $f(a)$ and $c$ (and, since it's an interval, everything in between) for all $\delta > 0$. Then there is a sequence $x_n$ such that $|x_n - a| < 1/n$ and $f(x_n) = (1 - 1/n) c + (1/n) f(a)$. Then $K = \{a\} \cup \{x_n: n \in {\mathbb N}\}$ is a compact set, $c$ is a limit point of $f(K)$, but $c \notin f(K)$, contradiction.

EDIT: The question for functions $f$ from ${\mathbb R}^n$ to ${\mathbb R}^m$ also seems interesting. Suppose such an $f$ maps compact sets to compact sets and connected sets to connected sets, but is discontinuous at $a$. Let $B_\delta(p)$ be the closed ball of radius $\delta$ centred at $p$ and $S_\delta(p)$ the sphere of radius $\delta$ centred at $p$ (in either ${\mathbb R}^n$ or ${\mathbb R}^m$ depending on the context). There is $\epsilon > 0$ such that for all $\delta > 0$, $f(B_\delta(a))$ is not contained in $B_\epsilon(f(a))$. For every $r \in (0,\epsilon)$, since $f(B_\delta(a))$ is connected, $f(B_\delta(a)) \cap S_r(f(a))$ must be nonempty. In particular we can take $x_n$ with $\|x_n - a\| \le 1/n$ and $\|f(x_n) - f(a)\| = (1-1/n) \epsilon$. Again we get a contradiction, taking $K = \{a\} \cup \{x_n: n \in {\mathbb N}\}$.


I have an alternative answer:

Suppose $f:\mathbb{R}^n\longrightarrow{\mathbb{R}^m}$ sends connected sets onto connected sets and compact sets onto compact sets. We want to show $f$ is continuous. Suppose not,then there is $a\in{R}$ and $\epsilon>0$ such that for every $n\in{N}$ there is $x_n\in{B_{\frac{1}{n}}(a)}$ with $||f(x_n)-f(a)||>\epsilon$, since $f(\overline{B_{\frac{1}{n}}(a)})$ is connected and compact we must have that $(\overline{B_{\epsilon}(a)}-{B_{\frac{\epsilon}{2}}(a)})\cap{f(\overline{B_{\frac{1}{n}}(a)})}\neq{\emptyset}$ for all $n>1$, then $\{f(\overline{B_{\frac{1}{n}}(a)})\}_{n\in{\mathbb{N}}}\cup{\{\overline{B_{\epsilon}(f(a))}-{B_{\frac{\epsilon}{2}}(f(a))}\}}$ is a family of closed sets with a bounded element and the finite intersection property, then $(\bigcap_{n_\in{\mathbb{N}}}f(\overline{B_{\frac{1}{n}}(a)}))\cap{(\overline{B_{\epsilon}(f(a))}-{B_{\frac{\epsilon}{2}}(f(a))})}\neq{\emptyset}$, then there is $b\in{\bigcap_{n_\in{\mathbb{N}}}f(\overline{B_{\frac{1}{n}}(a)})}$ with $\frac{\epsilon}{2}<{||b-f(a)||}\leq{\epsilon}$, but we have that $\bigcap_{n_\in{\mathbb{N}}}(\overline{B_{\frac{1}{n}}(a)}))=\{a\}$, so $\bigcap_{n_\in{\mathbb{N}}}f(\overline{B_{\frac{1}{n}}(a)}))=\{f(a)\}$.A Contradiction.Hence $f$ must be continuous.