View pdf file in browser instead of downloading
You need to change the Content-disposition
to inline
.
Change
header("Content-disposition: attachment;
filename=".basename('theme/assets/pdf/ci.pdf'));
To:
header("Content-disposition: inline;
filename=".basename('theme/assets/pdf/ci.pdf'));
Opening files in browser instead of downloading
add target="_blank" to get a new window. adding .pdf may help. If you have control over the host web server adjusting the headers for the files in question will also help it open inline. I can tell you what headers to set if you are able too
Open Files in Browser instead of downloading (including files like .doc, .xls etc)
As far as I know, there are no client-side libraries exist that can open .doc, .docs, .xls in browser. There is a way to render render your files using browser is to use Google Documents' Viewer or Microsoft Office 365 viewer via an <iframe>
. Using this inside an <iframe>
you can open your file in side your browser but can not edit.
Google Documents' Viewer inside <iframe>
<iframe src="http://docs.google.com/gview?url=http://example.com/path/to/your/document.doc&embedded=true"></iframe>
Google Documents' Viewer clickable link <a>
<a href="http://docs.google.com/gview?url=http://example.com/path/to/your/document.doc&embedded=true">Open your doc file</a>
Microsoft Office 365 viewer <iframe>
<iframe src='https://view.officeapps.live.com/op/embed.aspx?src=http://example.com/path/to/your/document.doc' width='1366px' height='623px' frameborder='0'></iframe>
How to force open links in Chrome not download them?
To make certain file types OPEN on your computer, instead of Chrome Downloading...
You have to download the file type once, then right after that download, look at the status bar at the bottom of the browser. Click the arrow next to that file and choose "always open files of this type". DONE.
Now the file type will always OPEN using your default program.
To reset this feature, go to Settings / Advance Settings and under the "Download.." section, there's a button to reset 'all' Auto Downloads
Hope this helps.. :-)
Visual Instructions found here:
http://www.presentermedia.com/blog/2013/10/my-file-automatically-opens-instead-of-saving-with-chrome/
Controller opens file in the browser instead of downloading it
Removing response.flushBuffer();
has fixed my issue.
Related Topics
How to Write Data to a Text File Without Overwriting the Current Data
How to Parse Json List or Object in C#
How to Set Value of Wpf Combobox Item from C# Code
How to Access a Form Control for Another Form
Digital Sign With Sha256 With C#
C# Multipart/Form-Data Submit Programmatically
Finding Closest Value in an Array
Get and Post Methods With the Same Action Name in the Same Controller
Linq - Select Date from Datetime
Linq to Find All Childs Related to Parents Id
Removing Elements from Json Based on a Condition in C#
Calling a Function from Another Class in C#/.Net MVC App
How to Call a Method Daily, At Specific Time, in C#
How to Iterate Through the Following Json Using C#
How to Check If a Datetime Value Is Empty or Not in a Put Request
How to Turn Off Brackets/Quotes Auto-Completion in Visual Studio