Skip to content

Instantly share code, notes, and snippets.

@sohelrana820
Last active July 12, 2022 08:20
Show Gist options
  • Save sohelrana820/e436400419a7aee07b071e67636d5202 to your computer and use it in GitHub Desktop.
Save sohelrana820/e436400419a7aee07b071e67636d5202 to your computer and use it in GitHub Desktop.
Delete file after download
```php
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . $zip['name']);
header('Content-Transfer-Encoding: binary');
header('Connection: Keep-Alive');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
//header('Content-Length: ' . $size);
readfile($zip['path']);
$file = new \Cake\Filesystem\File($zip['path']);
$file->delete();
exit();
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment