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
https://forums.phpfreaks.com/topic/29431-remove-file-once-download-is-completed/
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.
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.