# Howto open PDF files in same browser window?

**URL:** https://meta.discourse.org/t/howto-open-pdf-files-in-same-browser-window/25823
**Category:** Feature
**Created:** [February 28, 2015, 3:00am UTC](https://meta.discourse.org/t/howto-open-pdf-files-in-same-browser-window/25823 "2015-02-28T03:00:39Z")
**Posts on this page:** 3
**Page:** 2

<div class="post-metadata">

### Author: ![terraboss](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/terraboss/32/381157_2.png) [@terraboss](https://meta.discourse.org/u/terraboss)
#### Post date: [March 23, 2019, 7:57pm UTC](https://meta.discourse.org/t/howto-open-pdf-files-in-same-browser-window/25823/21 "2019-03-23T19:57:25Z")

</div>

Unfortunately, no. 🙄

---

<div class="post-metadata">

### Author: ![Hilario](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hilario/32/152199_2.png) [@Hilario](https://meta.discourse.org/u/Hilario)
#### Post date: [April 27, 2020, 7:50am UTC](https://meta.discourse.org/t/howto-open-pdf-files-in-same-browser-window/25823/22 "2020-04-27T07:50:10Z")

</div>

Hello, get the same problem.  
PDF file does not display but always download , whatever config I have on my explorer (chrome, firefox)  
From what I am reading this is related with content\_type for the file  
I have found this

> Great question! What defines that action is the “Content-type” header sent from the server to the client. You can define the value of this header using s3-compatible tooling. There is a good explanation of this here:

[https://stackoverflow.com/questions/39832289/pdfs-in-amazon-s3-dont-open-in-chrome-for-view](https://stackoverflow.com/questions/39832289/pdfs-in-amazon-s3-dont-open-in-chrome-for-view)

But I haven’t been able to progress.  
It seams the issue is indicate Content-Type or content-disposition but I don’t know if I have to do it at uploading,  
Perhaps some expert can help us.

---

<div class="post-metadata">

### Author: ![Hilario](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hilario/32/152199_2.png) [@Hilario](https://meta.discourse.org/u/Hilario)
#### Post date: [April 27, 2020, 8:06am UTC](https://meta.discourse.org/t/howto-open-pdf-files-in-same-browser-window/25823/23 "2020-04-27T08:06:42Z")

</div>

I found this information more clear than the previous one.  
My problem is I don’t know how to use it to solve the situation. 😭

> If you want the browser to treat the file as pdf you should let him know that his file is a pdf. The way to do so is to send the relevant header:  
> Content-type: application/pdf
> 
> The current header that is sent by s3 is:  
> Contant-type: application/octet-stream
> 
> Since you upload the files to s3 - you can either set the correct mime-type for the file during uploading, or afterward using some of the s3 tools (like s3cmd for windows, for example).
> 
> According to the link to the documentation you provided, the putObjectFile function is deprecated, but this is the definition:  
> putObjectFile (string $file, string $bucket, string $uri, [constant $acl = S3::ACL\_PRIVATE], [array $metaHeaders = array()], [string $contentType = null])
> 
> As you can see - the last parameter is contentType - so you can set it to application/pdf when uploading the file.  
> This will set the correct header when downloading

[Previous page](https://meta.discourse.org/t/howto-open-pdf-files-in-same-browser-window/25823.md?page=1)
