Jump to content

Remove file once download is completed


Emir

Recommended Posts

Hello,

Basically, I am wanting something like this to happen: A php script copies a file from a directory that is unreadable by the public to a directory is readable. The person then downloads this file and somehow the file is deleted afterwards. Is there a way to detect when a person is done downloading a file?

I am not sure if this is a good or even feasible way of accomplishing what I want. If you know how to do this, of some tutorials, or any other alternative method, please let me know. I simply am wanting to make a site where someone purchases a "file" and the file is delivered to them while keeping the files unreadable at their source.

Any help would be greatly appreciated!

Thank you,
Emir
Link to comment
Share on other sites

I will not provide you with a script...however, I will point you in the right direction:

[code]
<?php

  header("Cache-control: private");
  header("Content-type: application/force-download");
  header("Content-transfer-encoding: binary\n");
  header("Content-disposition: attachment; filename=\"$filename\"");

  readfile($directory.'/'.$filename);
  unlink($directory.'/'.$filename);

?>[/code]

You need to modify this and implement it into your code. But please do not come on here asking for scripts.
Link to comment
Share on other sites

If you're going to be selling something or dealing with ecommerce, I suggest not coding it yourself if you lack the experience. Far too much liablity and problems.

http://www.turnkeywebtools.com/products.php?p=ss-shopping-cart-software

That software (Coded in PHP) supports digital downloads already. And they provide support for it.
Link to comment
Share on other sites

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.