<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                **網頁強制下載或者直接打開PD或以及header和content-type參數** * * * * * 我們經常會看到在網頁中點擊一個文件,比如pdf的,它有的是直接在網頁中打開,有的是提示下載,這兩種效果怎么實現的呢?: **php 網頁直接打開PDF** ~~~ header('Content-type: application/pdf'); header('filename='.$fname); //隨便一個名字都可以 readfile($pfname); //file的相對地址 ~~~ **php 強制下載PDF文件** ~~~ header('Content-type: application/pdf'); header('Content-Disposition: attachment; filename='.$fname); //隨便一個名字都可以 readfile($pfname); //file的相對地址 ~~~ 就這么簡單 * * * * * 以下是關于header和content-type參數詳解 header()是用來發送 HTTP Header的。replace是個可選的參數,指示是否替代一個先期相似的header,或者增加第2個相同類型的header。默認的是替 代,但是如果你傳遞FALSE參數給第2個參數(即replace),你能強制使用多個相同類型的header。例如: ~~~ <?php header(’WWW-Authenticate: Negotiate’); header(’WWW-Authenticate: NTLM’, false); ?> ~~~ 第 二個可選的參數http_response_code強置HTTP響應代碼的值。(PHP>4.3.0)有兩種特定的 header調 用。一種是header用字符串”HTTP/”開頭的(大小寫無所謂),它用來指定發出的HTTP狀態碼。舉個例子來說,如果你已經配置 Apache使用javascript:;" onClick="javascript:tagshow(event, 'PHP');" target="_self">PHP腳 本來處理請求不存在的文件(用ErrorDocument指令),你可能想確認你的腳本生成一個合適的狀態碼: ~~~ <?php header(”HTTP/1.0 404 Not Found”); ?> ~~~ 注意:HTTP狀態行 總是最先發送給客戶端的,不管你實際上在什么時候調用header()函數。除非你的HTTP header已經發送出去了,否則,在任何時候,狀態將會被header()函數用一個新的狀態行 覆蓋。 在PHP 3中,只有PHP編譯為Apache的模塊是,并且用下面Staus Header才能取得同樣的效果 ~~~ <?php header(”Status: 404 Not Found”); ?> ~~~ 第二中特殊的情況就是”Location:”header。如果沒有某些 3xx的狀態碼已經發出的話,它不僅發出Location行,而且發出一個重定向的狀態碼(302)。 ~~~ <?php header(”Location: http://www.wycto.com”); exit; ?> ~~~ 注意:HTTP/1.1要求一個絕對 URI作為Location的參數:包括協議頭,主機名和絕對路徑,但是某些客戶端可以接受相對URI。你可 用$_SERVER['HTTP_HOST'] $_SERVER['PHP_SELF']和dirname()來從一個相對URI來產生絕對 URI。 ~~~ <?php header(”Location: http://” . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . “/” . $relative_url); ?> ~~~ PHP腳本通常生成一些動態的內容,不必被客戶端的瀏覽器或者代理服務器緩 存。許多代理和客戶端可以強制禁止緩存: ~~~ <?php // 時間總是過去的 header(”Expires: Mon, 26 Jul 1997 05:00:00 GMT”); // 文件總是被修改的 header(”Last-Modified: ” . gmdate(”D, d M Y H:i:s”) . ” GMT”); // HTTP/1.1 header(”Cache-Control: no-store, no-cache, must-revalidate”); header(”Cache-Control: post-check=0, pre-check=0″, false); // HTTP/1.0 header(”Pragma: no-cache”); ?> ~~~ 注意:你可能發現即使你沒有輸出上面的header,你的頁面還是不能被 緩存。可能是有幾個選項改變了默認的緩存行為。見sessrion_cache_limiter(). 如果你想提示用戶保 存你 發送過去的數據,比如一個已經生成的PDF文件,你可以用Content_Dispostion頭來提供一個推薦的文件名,強迫瀏覽器顯示保存對 話框. ~~~ <?php header(’Content-type: application/pdf’); header(’Content-Disposition: attachment; filename=”downloaded.pdf”‘); readfile(’original.pdf’); ?> ~~~ 對 于IE,要加上Connection頭 ~~~ header(”HTTP/1.1 301 Moved Permanently”); header(”Location: “.$url); header(”Connection: close”); ~~~ header 中Content-type的種類: ~~~ 'hqx' -> 'application/mac-binhex40', 'cpt' -> 'application/mac-compactpro', 'doc' -> 'application/msword', 'bin' -> 'application/octet-stream', 'dms' -> 'application/octet-stream', 'lha' -> 'application/octet-stream', 'lzh' -> 'application/octet-stream', 'exe' -> 'application/octet-stream', 'class' -> 'application/octet-stream', 'so' -> 'application/octet-stream', 'dll' -> 'application/octet-stream', 'oda' -> 'application/oda', 'pdf' -> 'application/pdf', 'ai' -> 'application/postscript', 'eps' -> 'application/postscript', 'ps' -> 'application/postscript', 'smi' -> 'application/smil', 'smil' -> 'application/smil', 'mif' -> 'application/vnd.mif', 'xls' -> 'application/vnd.ms-excel', 'ppt' -> 'application/vnd.ms-powerpoint', 'wbxml' -> 'application/vnd.wap.wbxml', 'wmlc' -> 'application/vnd.wap.wmlc', 'wmlsc' -> 'application/vnd.wap.wmlscriptc', 'bcpio' -> 'application/x-bcpio', 'vcd' -> 'application/x-cdlink', 'pgn' -> 'application/x-chess-pgn', 'cpio' -> 'application/x-cpio', 'csh' -> 'application/x-csh', 'dcr' -> 'application/x-director', 'dir' -> 'application/x-director', 'dxr' -> 'application/x-director', 'dvi' -> 'application/x-dvi', 'spl' -> 'application/x-futuresplash', 'gtar' -> 'application/x-gtar', 'hdf' -> 'application/x-hdf', 'js' -> 'application/x-javascript', 'skp' -> 'application/x-koan', 'skd' -> 'application/x-koan', 'skt' -> 'application/x-koan', 'skm' -> 'application/x-koan', 'latex' -> 'application/x-latex', 'nc' -> 'application/x-netcdf', 'cdf' -> 'application/x-netcdf', 'sh' -> 'application/x-sh', 'shar' -> 'application/x-shar', 'swf' -> 'application/x-shockwave-flash', 'sit' -> 'application/x-stuffit', 'sv4cpio' -> 'application/x-sv4cpio', 'sv4crc' -> 'application/x-sv4crc', 'tar' -> 'application/x-tar', 'tcl' -> 'application/x-tcl', 'tex' -> 'application/x-tex', 'texinfo' -> 'application/x-texinfo', 'texi' -> 'application/x-texinfo', 't' -> 'application/x-troff', 'tr' -> 'application/x-troff', 'roff' -> 'application/x-troff', 'man' -> 'application/x-troff-man', 'me' -> 'application/x-troff-me', 'ms' -> 'application/x-troff-ms', 'ustar' -> 'application/x-ustar', 'src' -> 'application/x-wais-source', 'xhtml' 'application/xhtml+xml', 'xht' -> 'application/xhtml+xml', 'zip' -> 'application/zip', 'au' -> 'audio/basic', 'snd' -> 'audio/basic', 'mid' -> 'audio/midi', 'midi' -> 'audio/midi', 'kar' -> 'audio/midi', 'mpga' -> 'audio/mpeg', 'mp2' -> 'audio/mpeg', 'mp3' -> 'audio/mpeg', 'aif' -> 'audio/x-aiff', 'aiff' -> 'audio/x-aiff', 'aifc' -> 'audio/x-aiff', 'm3u' -> 'audio/x-mpegurl', 'ram' -> 'audio/x-pn-realaudio', 'rm' -> 'audio/x-pn-realaudio', 'rpm' -> 'audio/x-pn-realaudio-plugin', 'ra' -> 'audio/x-realaudio', 'wav' -> 'audio/x-wav', 'pdb' -> 'chemical/x-pdb', 'xyz' -> 'chemical/x-xyz', 'bmp' -> 'image/bmp', 'gif' -> 'image/gif', 'ief' -> 'image/ief', 'jpeg' -> 'image/jpeg', 'jpg' -> 'image/jpeg', 'jpe' -> 'image/jpeg', 'png' -> 'image/png', 'tiff' -> 'image/tiff', 'tif' -> 'image/tiff', 'djvu' -> 'image/vnd.djvu', 'djv' -> 'image/vnd.djvu', 'wbmp' -> 'image/vnd.wap.wbmp', 'ras' -> 'image/x-cmu-raster', 'pnm' -> 'image/x-portable-anymap', 'pbm' -> 'image/x-portable-bitmap', 'pgm' -> 'image/x-portable-graymap', 'ppm' -> 'image/x-portable-pixmap', 'rgb' -> 'image/x-rgb', 'xbm' -> 'image/x-xbitmap', 'xpm' -> 'image/x-xpixmap', 'xwd' -> 'image/x-xwindowdump', 'igs' -> 'model/iges', 'iges' -> 'model/iges', 'msh' -> 'model/mesh', 'mesh' -> 'model/mesh', 'silo' -> 'model/mesh', 'wrl' -> 'model/vrml', 'vrml' -> 'model/vrml', 'css' -> 'text/css', 'html' -> 'text/html', 'htm' -> 'text/html', 'asc' -> 'text/plain', 'txt' -> 'text/plain', 'rtx' -> 'text/richtext', 'rtf' -> 'text/rtf', 'sgml' -> 'text/sgml', 'sgm' -> 'text/sgml', 'tsv' -> 'text/tab-separated-values', 'wml' -> 'text/vnd.wap.wml', 'wmls' -> 'text/vnd.wap.wmlscript', 'etx' -> 'text/x-setext', 'xsl' -> 'text/xml', 'xml' -> 'text/xml', 'mpeg' -> 'video/mpeg', 'mpg' -> 'video/mpeg', 'mpe' -> 'video/mpeg', 'qt' -> 'video/quicktime', 'mov' -> 'video/quicktime', 'mxu' -> 'video/vnd.mpegurl', 'avi' -> 'video/x-msvideo', 'movie' -> 'video/x-sgi-movie', 'ice' -> 'x-conference/x-cooltalk' ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看