Open PDF in browser, not "Save As"

    Date: 01/22/10 (PHP Community)    Keywords: browser

    My users want an option to open stored PDFs in the browser window instead of being prompted to download the file.

    Current code:

    if(file_exists($file))
    		{
    			header('Content-Description: File Transfer');
    			header('Content-Type: application/octet-stream');
    			header('Content-Disposition: attachment; filename='.basename($file));
    			header('Content-Transfer-Encoding: binary');
    			header('Expires: 0');
    			header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    			header('Pragma: public');
    			header('Content-Length: ' . filesize($file));
    			ob_clean();
    			flush();
    			readfile($file);
    			exit;
    		}


    How would I write the headers to allow files to open in the browser window?

    Source: https://php.livejournal.com/676531.html

« Hmm... || Do x to items 1-7, then y... »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home