Reputation: 1078
I am using ZipArchive
library for downloading contents as archive.
The problem is that the archived file not getting full name that as given, its ending at first space. eg: if i am giving the file name as "new file.zip"
header('Content-disposition: attachment; filename = new file.zip');
While googling i found that just putting the quoted file name solves the problem. So i tried this:
header("Content-disposition: attachment; filename = 'new file.zip'");
but nothing changes, while downloading the file name changes to "new.zip", what i have to get is "new file.zip"
The problem is only with firefox
Upvotes: 1
Views: 304
Reputation: 23256
Set the content type as application/zip, application/octet-stream
before you make the file download and include the filename
in double quotes.
// We'll be outputting a ZIP
header('Content-Type: application/zip, application/octet-stream');
// It will be called new file.zip
header('Content-Disposition: attachment; filename="new file.zip"');
If you pass the variable filename, that could have spaces:
header("Content-Disposition", "attachment; filename=\"" . $fileName ."\"");
Note that the filename
is surrounded by double quotes
, per RFC 2231. This allows for the use of extended characters within the filename (i.e., international characters).
Upvotes: 1