0

I am using Slim Framework 3. Here's my code:

....
    $response = $response->withStatus(200)
                        ->withHeader('X-Sendfile', $path)
                        ->withHeader('Content-Type', $contentType)
                        ->withHeader('Content-disposition:', 'attachment; filename=' . $fileName);
                    return $response;
....

When using through postman, I see the image. But, how do I show the image / video / audio on an html page using the response?

4

1 回答 1

0

由于整个文件由 x-sendfile 返回,因此该文件实际上是一个blob。因此,我在我的 javascript 中设置了responseType我的 ajax 请求。blob我按照@AdamZ 在Using Javascript to Display Blob上的回答,一切正常。

于 2016-01-06T08:28:26.423 回答