/    Sign up×
Community /Pin to ProfileBookmark

Which headers to define for file export over https?

Hi folks,

I’m trying to output a .csv format file for download via php, but over a secure connection (https). I have been using the following headers, but have found that in Google Chrome, the file name is not being generated. Instead, the file is being named the same as the script generating it!?

Are these even the right headers to use? unexpected results in Safaris as well, in that when you try to open/save the file, an error occurs saying that the file has been moved and cannot be found.

Thanks

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@pavsidauthorJul 29.2010 — Sorry i forgot to post the headers!!

But i have solved it anyway - i was missing a quote at the end of the filename.

For anybody else's benefit, here are the headers to use.


[code=php]
header('Content-type: application/octet-stream');
header('Content-Disposition: attachment; filename="filename.csv"');
header('Expires: 0');
header('Cache-Control: private');
header('Pragma: cache');
[/code]
×

Success!

Help @pavsid spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...