Search code examples
jqueryjquery-file-upload

jQuery File Upload delete uploaded files onbeforeunload


I am using jQuery File Upload plugin by blueimp and everything works fine. But I've just realized that if users upload files and navigate away from the page without completing the form, it will create "orphan" files.

Is there a way to delete files onbeforeunload?


Solution

  • There is, but its not guaranteed to work 100% of the time.

    To make sure temp files don't pile up you have to implement some sort of 'garbage collection'. You can do it in a cron job, or with a certain probability on every upload request.