-3
Colleagues. Is it possible to open a PDF file directly inside the browser? I tried file_get_contents() and fopen(), but it opened decoded. So I tried that way, but it opened in the entire browser:
$arquivo='0eb178d150b82f5536588fbfea5fa7bd.pdf';
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="0eb178d150b82f5536588fbfea5fa7bd.pdf"');
@readfile($arquivo);
The first question is, did you send the correct mime-type on the headers? As you already have a site time, you should know that if you post your code, it is easier to locate the possible problems.
– Bacco
Hello Bacco, you’re right, I forgot to put the code. I edited my question.
– user24136
I just don’t think it’s right for them to give us a negative sign before we manifest, because this is a matter of urgency, and by closing the topic, it will slow down those who really need help. The right thing to do is to wait for the person who posted the doubt to answer the question before giving negative points.
– user24136
Try without the @ to see if there is an error. And don’t worry about the negative, it doesn’t close the question. By the way, if you left without the code, it would be normal to close as "not clear", but this is different from negative.
– Bacco
Right Bacco. The problem is that it opens in the entire browser and only need to open inside a div...
– user24136
Well, the last Dit has already changed the issue completely. If you want to download, exchange the application/pdf for application/octet-stream, if you want to open it in a div, then only with an IFRAME or new window. In IFRAME I don’t know if I can, to tell you the truth.
– Bacco
I changed it, but he asks me to change it...
– user24136
I get it......
– user24136