Delete file on browser close?
Is there a way to delete a server-side file if the browser is closed?
I have a pop-up window that allows a user to send an email to someone that will have a file attachment. Currently, the file data is read from a VARBINARY(MAX) column in a database and created/saved in a folder that is created for it (with a unique name for the directory) when the pop-up first loads. When the form is submit, the file is emailed then deleted and the directory for it is removed.
If the user changes his/her mind and closes the pop-up without hitting submit, the file and directory are left. I'd like to be able to delete the file and remove the directory if the pop-up is closed without hitting submit.
If only server-side scripting can do this, how can I trigger the script to run when the browser is closed?
You'll need to employ some form of garbage collection similar to what is done with session files. Pick a timeout for the files and run a script at an interval to delete them when they are too old.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread