I can ... but you won't give me support as the files are modified
But I think this is a general problem.
If I am right, you are storing the files in gallery/files/u/s/e/r/i/d
Directory files is owned by me and chmodded ugo+rw, so all fine here.
Now, the first call of mkdir() creates directory 'u', which is then being owned by user apache.
So any further calls to create directories s,e,r,i,d will fail if safe mode is turned on.