Welcome Guest, Not a member yet? Register   Sign In
Delete file after downloaded
#1

[eluser]Guntars[/eluser]
I just need to create txt file for user, and then after file is downloaded. I want to delete it from server.
Does anyone can help me with code, how to delete the file after file is downloaded successfully, I was look in google and can't find clean solution.

How to create I know.

Thanks.
#2

[eluser]gao[/eluser]
Hello. You have to download the file with a PHP, so when the file were downloaded, you could make a unlink(). See http://w-shadow.com/blog/2007/08/12/how-...-with-php/ for example for PHP or see Download Helper
#3

[eluser]pistolPete[/eluser]
If it's just a plain text file, you don't need to create an actual file.
Just generate the content and use the download helper: user guide
Code:
// generate the content, use a model function or whatever
$content = generate_content();
$this->load->helper('download');
// send the file to the user
force_download('some_file.txt', $content);
#4

[eluser]Guntars[/eluser]
Thanks that's looks exact what I need




Theme © iAndrew 2016 - Forum software by © MyBB