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?

alexw
  • 8,468
  • 6
  • 54
  • 86
Samar Rizvi
  • 300
  • 1
  • 9

1 Answers1

0

As the whole file is returned by x-sendfile, the file is actually a blob. Hence I set the responseType of my ajax request to blob in my javascript. I following the answer by @AdamZ here at Using Javascript to Display Blob and everything worked.

Community
  • 1
  • 1
Samar Rizvi
  • 300
  • 1
  • 9