dcsimg
www.webdeveloper.com
Results 1 to 2 of 2

Thread: Delete file on browser close?

  1. #1
    Join Date
    Dec 2002
    Location
    St. Louis, MO, USA
    Posts
    1,582

    Delete file on browser close?

    Hello, everyone.

    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.

    Can this be done with JavaScript? Or can this only be done with a dynamic server-side scripting language like PHP, ASP, ColdFusion?

    If only server-side scripting can do this, how can I trigger the script to run when the browser is closed?

    Thanks,

    ^_^

  2. #2
    Join Date
    Jan 2009
    Posts
    3,346
    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles