![]() |
Delete file after download - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Delete file after download (/showthread.php?tid=79320) |
Delete file after download - MatheusCastro - 05-27-2021 I have a situation that should download and delete the file. Is there any possibility? I'm using this function in response: PHP Code: return $response->download($name, $data); Anything like that, for example: PHP Code: // Other framework This is the bad solution? PHP Code: Controller: Im using PHP Spreedsheet library. RE: Delete file after download - InsiteFX - 05-28-2021 To delete a file you use unlink(path/filename); RE: Delete file after download - MatheusCastro - 05-28-2021 (05-28-2021, 02:35 AM)InsiteFX Wrote: To delete a file you use unlink(path/filename); Yes, okay! But the main question is whether there is any way to use the download with the response and delete it afterwards? Or if the solution would be the way I posted below not to use response->download. RE: Delete file after download - InsiteFX - 05-28-2021 This may help not sure. CodeIgniter 4 User Guide - Uploaded Files RE: Delete file after download - demyr - 05-29-2021 You can trigger a delete function via jquery / ajax when you click the download button. |