Download the PHP package cardinalby/content-disposition without Composer
On this page you can find all versions of the php package cardinalby/content-disposition. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package content-disposition
PHP class for handling (parsing and formatting) a value of HTTP
Content-Disposition
header.
Requires PHP 5.6 or newer.
Installation
Content-Disposition header
The text value of the header is in ISO-8859-1 charset. The header contains:
Type
. Can beattachment
,inline
or custom.filename
parameter that contains ISO-8859-1 compatible file name.filename*
parameter that contains a file name in a custom charset (with charset specified and URL-encoded)
API
🔻 static create(...)
🔸 $fileName
File name, can contain Unicode symbols. Depending on the symbols present in the string, value will be placed to
filename
or filename*
param.
Pass null
to omit filename
param.
🔸 $fallback
If the $filename
argument is outside ISO-8859-1, then the file name is actually
stored in a supplemental filename*
field for clients that support Unicode file names and
a ISO-8859-1 version of the file name is automatically generated.
This specifies the ISO-8859-1 file name to override the automatic generation or disables the generation at all.
true
(default) will enable automatic generation if the file name is outside ISO-8859-1. Replaces non-ISO-8859-1 characters with '?' character.- A string will specify the ISO-8859-1 file name to use in place of automatic
generation. If it differs from
$filename
, then$filename
option is encoded in the extended field and$fallback
set as the fallback field, even though they are both ISO-8859-1 false
will disable including a ISO-8859-1 file name and only include the Unicode version (unless the file name is already ISO-8859-1).null
will strictly disable including a ISO-8859-1 file name and only include the Unicode version even if file name is already ISO-8859-1.
🔸 $type
Specifies the disposition type, defaults to "attachment"
. This can also be
"inline"
, or any other value (all values except inline are treated like
attachment
, but can convey additional information if both parties agree to
it). The type is normalized to lower-case.
🔻 static createAttachment(...)
A shortcut for ContentDisposition::create($filename, $fallback, 'attachment')
;
🔻 static createInline(...)
A shortcut for ContentDisposition::create($filename, $fallback, 'inline')
;
🔻 format()
Generates the header string value (without header name).
🔻 formatHeaderLine()
Generates the full header line: Content-Disposition: ...
, where ...
equals format()
result.
🔻 static parse()
Parses a Content-Disposition
header string and returns ContentDisposition
object.
🔻 getType()
Returns the download type
🔻 getFilename()
Returns a value of filename*
param or (if doesn't exist) a value of filename
param or null
(if none exists).
🔻 getParameters()
Get associative array of all parameters including filename
and filename*
.
🔻 getCustomParameters()
Get associative array of unknown parameters (except filename
and filename*
).
References
Reference implementation: content-disposition library for NodeJS.
- RFC 2616: Hypertext Transfer Protocol -- HTTP/1.1
- RFC 5987: Character Set and Language Encoding for Hypertext Transfer Protocol (HTTP) Header Field Parameters
- RFC 6266: Use of the Content-Disposition Header Field in the Hypertext Transfer Protocol (HTTP)
- Test Cases for HTTP Content-Disposition header field (RFC 6266) and the Encodings defined in RFCs 2047, 2231 and 5987
License
MIT