in reply to cgi and upload_hook
Thing is, there's no way to tell for sure where inside the passed data any specific variable is until the entire batch of data is processed, since browsers can pass the fields in any order. So the entire data feed has to be processed first. This means that your hook probably won't be able access the $cgi variable, since the hook runs during the processing. You'll just have to live with that.