Open file in upload rather than at planning stage

When opening a directory with many files the open file descriptor limit can be hit.