I fixed a bug for portrait upload which should fix this I think see
http://cvs.openacs.org/cvs/openacs-4/packages/acs-subsite/www/user/portrait/upload-2-postgresql.xql?r1=1.4&r2=1.3the fix will be in 5.1.1 (or you could try making that
change locally to see if thats it or if it's something else).