If this is on the mod_form, then processing the file and then throwing it away feels like the wrong approach.
Most activity plugins use a filemanager element, not a filepicker element there, then stores the file using the API (and possibly does some processing on it when submitted).
See mod/resource for an example (or mod/scorm, if you want a more complex example where some processing is done on the submitted file).