function _filefield_source_remote_parse_header in FileField Sources 6
Same name and namespace in other branches
- 7 sources/remote.inc \_filefield_source_remote_parse_header()
Parse cURL header and record the filename specified in Content-Disposition.
1 string reference to '_filefield_source_remote_parse_header'
- filefield_source_remote_value in sources/
remote.inc - A #filefield_value_callback function.
File
- sources/
remote.inc, line 244 - A FileField extension to allow referencing of existing files.
Code
function _filefield_source_remote_parse_header(&$ch, $header) {
if (preg_match('/Content-Disposition:.*?filename="(.+?)"/', $header, $matches)) {
// Content-Disposition: attachment; filename="FILE NAME HERE"
_filefield_source_remote_filename($matches[1]);
}
elseif (preg_match('/Content-Disposition:.*?filename=([^; ]+)/', $header, $matches)) {
// Content-Disposition: attachment; filename=file.ext
$uri = trim($matches[1]);
_filefield_source_remote_filename($uri);
}
// This is required by cURL.
return strlen($header);
}