Motility is a basic feature of living microorganisms, and how it works is often determined by environmental cues. Recent efforts have focused on developing artificial systems that can mimic microorganisms, in particular their self-propulsion. We report on the design and characterization of synthetic self-propelled particles that migrate upstream, known as positive rheotaxis. This phenomenon results from a purely physical mechanism involving the interplay between the polarity of the particles and their alignment by a viscous torque. We show quantitative agreement between experimental data and a simple model of an overdamped Brownian pendulum. The model notably predicts the existence of a stagnation point in a diverging flow. We take advantage of this property to demonstrate that our active particles can sense and predictably organize in an imposed flow. Our colloidal system represents an important step toward the realization of biomimetic microsystems with the ability to sense and respond to environmental changes.