Not sure if this is the best way, but we can compute a Grobner basis $B$ of $I$, expressing its generators in terms of $f_i$. Any $g\in I$ reduces to $0$ w.r.t. $B$, which gives a representation of $g$ in terms of polynomials in $B$, which then translates into a representation of $g$ in terms of $f_i$.
ADDED. Here is a more transparent way at the cost of adding a new variable $y_i$ for each $f_i$. Let $B'$ be a Grobner basis of $\langle f_i-y_i\rangle$ w.r.t. the elimination order weighting $x$'s more than $y$'s. Then a polynomial $g\in I$ reduces w.r.t. $B'$ to a polynomial $h(y_1,\dots,y_n)$ with coefficients being polynomials in $x$'s and $h(0,\dots,0)=0$, giving the required representation $g=h(f_1,\dots,f_n)$.