I was participating The "Ask the ClariFit Experts" Webinar where Martin Giffy D'Souza and Chris Hritzuk was presenting PL/SQL, SQL and APEX tricks.
Martin did present good tip "tag" files uploaded to WWV_FLOW_FILES using On Submit and Before Computation page process. That way you can easily later identify and delete files left to WWV_FLOW_FILES if validation error is raised on upload page and all page processes are not run. He have also previous write blog post relating topic.
I have used for this purpose code in validation. This validation is run only if some other validation is not passed. Actually this code is not for validating anything and never raise error. Code is on validation section because APEX page processing logic on page submission. It is important that this validation block have highest sequence number that it is executed last.
Create page level new validation.
Set Display Error Location to On Error Page. NOTE! Make sure this validation sequence number is highests of validations on page.
Validation type PL/SQL.
Select PL/SQL Error.
DELETE FROM wwv_flow_files
WHERE name = :Px_FILE_BROWSER
Remember change Px_FILE_BROWSER to be you file browser item name.
Enter something to Error Message. It is not important as this is not actual validation.
Set Always Execute to Yes.
Set condition Inline Validation Errors Displayed.
Now WWV_FLOW_FILES keep clean even end user gets some validation errors when uploading file. This trick is very useful for form pages where user enter data and load files to database.