src/Leevel/Http/FileResponse.php
public function setContentDisposition(string $disposition, string $filename = ''): IResponse
    {
        if ($this->checkFlowControl()) {
            return $this;
        }

        if ('' === $filename) {
            $filename = $this->file->getFilename();
        }

        if (!in_array($disposition, [
            ResponseHeaderBag::DISPOSITION_ATTACHMENT,
            ResponseHeaderBag::DISPOSITION_INLINE,
        ], true)) {
            throw new InvalidArgumentException('The disposition type is invalid.');
        }

        $this->headers->set(
            'Content-Disposition',
            sprintf('%s; filename="%s"', $disposition, str_replace('"', '\\"', basename($filename)))
        );

        return $this;
    }
public function setContentDisposition(string $disposition, string $filename = ''): IResponse
    {
        if ($this->checkFlowControl()) {
            return $this;
        }

        if ('' === $filename) {
            $filename = $this->file->getFilename();
        }

        if (!in_array($disposition, [
            ResponseHeaderBag::DISPOSITION_ATTACHMENT,
            ResponseHeaderBag::DISPOSITION_INLINE,
        ], true)) {
            throw new InvalidArgumentException('The disposition type is invalid.');
        }

        $this->headers->set(
            'Content-Disposition',
            sprintf('%s; filename="%s"', $disposition, str_replace('"', '\\"', basename($filename)))
        );

        return $this;
    }
设置文件下载模式.

@param string $disposition
@param string $filename

@return $this