File upload

Fixes for #1650