This is a reasonable example that demonstrates how to use filemanager:
https://github.com/AndyNormore/filemanager
(I'd probably use file_prepare_standard_filemanager() and file_postupdate_standard_filemananger(), as that does some of the work for you, but that is just a wrapper for the file_prepare_draft_area(), etc. functions, so does the same thing in the end)