Skip to content

Commit

Permalink
content-disposition filename bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
rauwebieten committed Sep 13, 2017
1 parent 9785bac commit 866f378
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Psr7PartialDownload.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ public function sendFile(ServerRequestInterface $request, ResponseInterface $res
$byteOffset = 0;
$byteLength = $fileSize = filesize($filePath);

// clean up filename
$invalidChars = array('<', '>', '?', '"', ':', '|', '\\', '/', '*', '&');
$fileName = str_replace($invalidChars, '', $fileName);

$response = $response->withHeader('Accept-Ranges', 'bytes');
$response = $response->withHeader('Content-Disposition', "attachment; filename=$fileName");
$response = $response->withHeader('Content-Disposition', "attachment; filename=\"{$fileName}\"");

$server = $request->getServerParams();

Expand Down

0 comments on commit 866f378

Please sign in to comment.