improved file upload to store file metadata in db