Jump to content

Recommended Posts

I have a shopping cart  application that stores a customers purchases in a specific directory made available for download via clicking on a link.

I would like to destroy the directory ( and purchases) within once a customer has made the download.

Could anyone suggest in principle, how to approach this. For example can the directory be set by a timescale to self destruct or can a download of a file be detected to trigger such an event.

 

 

Link to comment
https://forums.phpfreaks.com/topic/53401-deleting-a-download-directory/
Share on other sites

See glob(), unlink(), and rmdir().  Also see filemtime() for checking if a file is old enough to qualify for deletion.

 

You can put a file/directory deletion routine in one of your scripts to be run every time the script is run or only at certain times.  If you want to go outside of PHP, you can write a script to do so and set it via cron.  You can even write a daemon to sit around and check for old files and delete them.

On what OS are you running this?  cron is the scheduling daemon on Unix/Linux/etc.  That means you can set a script or program to execute at pre-determined periods, i.e., once a week, twice a day, on Friday, etc.  There are similar solutions available for Windows, but I am not familiar with them.  You'll probably have to have a little access to the system in order to use them, though.  If you won't be able to do that, that's why I also suggested putting the deletion routine in your scripts that will be commonly run.  It can be sort of like an "unprivileged" person's cron.  :)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.