Skip to content

Having trouble sending a file to the downloads folder #4332

Answered by oleibman
wranson22 asked this question in Q&A
Discussion options

You must be logged in to vote

It sounds like you are trying to download the file from a browser. If so, the following code adapted from samples/Basic/01_Simple_download_Xlsx should give you an idea how to proceed:

// Redirect output to a client’s web browser (Xlsx)
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="output.xlsx"'); // name changed to match sample code above
header('Cache-Control: max-age=0');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
header('Pragma: public'); // HTTP/1.0

$writer = IOFactory::createWriter($outputSp…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@wranson22
Comment options

@wranson22
Comment options

Answer selected by wranson22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants