The answer in a phrase is: valuative criterion for properness.
Let $O$ be any semi-local Dedekind domain, $K$ its fraction field, and $G$ a reductive $O$-group (such as ${\rm{GL}}_n$) admitting a Borel $O$-subgroup $B$ (such as the upper-triangular $O$-subgroup scheme of ${\rm{GL}}_n$). We will prove that $G(O) \rightarrow G(K)/B(K)$ is surjective in general. (It seems unlikely to be true for general principal ideal domains $O$ because domains finite etale over $O$ may not be PID's; such extensions emerge near the end of the proof below)
It is a general fact that if $H$ is a connected reductive group over a field and $P$ is a parabolic $F$-subgroup then the inclusion $H(F)/P(F) \hookrightarrow (H/P)(F)$ is bijective; in the special case $H = {\rm{GL}}_n$ and $P$ the upper-triangular subgroup, $H/P$ is the Grassmannian of full flags in an $n$-dimensional space and $H(F)$ visibly acts transitively on the collection of these, so in that case one sees the equality by bare hands. Hence, it suffices to prove that the natural map $G(O) \rightarrow (G_K/B_K)(K)$ is surjective.
The first crucial fact we need to use is that the sheaf $G/B$ over $O$ (whose $K$-fiber is represented by the familiar $G_K/B_K$) is represented by a proper $O$-scheme. For $G = {\rm{GL}}_n$ this is seen by bare hands using the Grassmannian $O$-scheme for full flags (but one needs a real argument with flatness to prove the required "transitivity" property, lying beyond just a statement on field-valued points). In general (for all reductive $O$-groups $G$ for any ring $O$) this is a very hard theorem even just over discrete valuation rings: see Corollary 5.2.8 in http://math.stanford.edu/~conrad/papers/luminysga3.pdf for a modern proof in general (resting on algebraic spaces).
Since $O$ is Dedekind, by the valuative criterion for properness we know that the set $(G_K/B_K)(K) = (G/B)(K)$ coincides with $(G/B)(O)$. Hence, we're reduced to proving $G(O) \rightarrow (G/B)(O)$ is surjective. If $G' \rightarrow \mathscr{D}(G)$ is the simply connected central isogenous cover of the semisimple derived group of $G$ (appropriately defined over $O$, but equal to ${\rm{SL}}_n$ for $G = {\rm{GL}}_n$) then $G/B = G'/B'$ for the Borel $O$-subgroup $B' \subset G'$ that is the full preimage of $B \subset G$. Hence, we can replace $G$ with $G'$ to reduce to the case that $G$ is simply connected. The purpose of this reduction step will emerge near the end, to get a result beyond the split case.
Since $G \rightarrow G/B$ is a $B$-torsor for the etale (or fppf, take your pick) topology, the fiber over an $O$-point of $G/B$ is a $B$-torsor over $O$. Hence, our task reduces to proving that the pointed set ${\rm{H}}^1(O, B)$ of $B$-torsors over $O$ is trivial. In general $B = T \ltimes U$ for an $O$-torus $T$ and a smooth affine $O$-group $U$ that has a composition series whose successive quotients are $\mathbf{G}_a$; for $G = {\rm{GL}}_n$ such a structure for $B$ is clear by bare hands and in general it rests on the existence of Levi subgroups for parabolic subgroups of reductive groups over rings; see Corollary 5.4.8 and Theorem 5.4.3 in the link above. Thus, ${\rm{H}}^1(O, U) = 0$ since ${\rm{H}}^1(O, \mathbf{G}_a) = 0$
(equality of fppf and etale cohomologies of quasi-coherent sheaves with Zariski cohomology, and the vanishing of higher Zariski cohomology for such sheaves on an affine scheme). It therefore suffices to show that ${\rm{H}}^1(O,T) = 1$.
If $T$ were split, as happens when $G$ is split (such as for ${\rm{GL}}_n$ or ${\rm{SL}}_n$), say $T = {\rm{GL}}_1^N$ for some $N$, then ${\rm{H}}^1(O,T) = {\rm{Pic}}(O)^{\oplus N} = 1$ (as $O$ is a PID), so we'd be done. What about the general case? Since $G$ has a Borel $O$-subgroup, by the general structure theory for quasi-split simply connected groups over rings it follows that necessarily $T = {\rm{R}}_{O'/O}(S')$ for a finite etale $O$-algebra $O'$ and a split $O'$-torus $S'$: see Prop. 7.2.11 and Prop. 7.2.12 of the above link for the case of adjoint type, and the same method applies verbatim in the simply connected case (the point being that the only feature used about adjoint type there is that automorphisms of the diagram necessarily respect the entire root datum in such cases, and this holds in the simply connected case too).
Since $O'$ is finite etale over $O$, we have $O' = \prod O'_j$ for semi-local Dedekind domains $O'_j$. In particular, each $O'_j$ is a PID. (If $O$ were merely a PID rather than actually semi-local then each $O'_j$ would be Dedekind but we would have no control on them being a PID or not.) The split $O'$-torus $S'$ restricts to a power $S'_j$ of ${\rm{GL}}_1$ over each ${\rm{Spec}}(O'_j)$ (th power perhaps depending on $j$). Thus, ${\rm{H}}^1(O,T) = {\rm{H}}^1(O',S') = \prod {\rm{H}}^1(O'_j, S'_j) = 1$ because each $O'_j$ is a PID. This completes the affirmative proof in general (any semi-local Dedekind $O$ and any reductive $O$-group scheme admitting a Borel $O$-subgroup).