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

(This post was last modified: 05-28-2021, 02:28 PM by MatheusCastro.)

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
return response()->download($filePath$fileName$headers)->deleteFileAfterSend(true); 

This is the bad solution?

PHP Code:
Controller:

// Set header content disposition file
header("Content-Disposition: attachment; filename=" $fileName);

// Force download writer to output
$writer->save('php://output');

// Remove file after download
unset($filePath);

// Break request to not corrupt the file
exit(); 

Im using PHP Spreedsheet library.
Reply


Messages In This Thread
Delete file after download - by MatheusCastro - 05-27-2021, 06:59 PM
RE: Delete file after download - by InsiteFX - 05-28-2021, 02:35 AM
RE: Delete file after download - by MatheusCastro - 05-28-2021, 03:12 AM
RE: Delete file after download - by InsiteFX - 05-28-2021, 09:01 PM
RE: Delete file after download - by demyr - 05-29-2021, 12:13 AM



Theme © iAndrew 2016 - Forum software by © MyBB