Two fixes for file upload related bugs

This closes #4825 and #4871