php文件没有在我的新笔记本电脑上打开



我有一个弹出在模式窗口中的表单,如下所示:

<?php
error_reporting(0);
require("../codebase/grid_connector.php");
include '../site_globals/dbc.php';
$mask5 = filter($_GET["var1"]);
//Get Category ID
$cat    = mysql_query("SELECT category FROM submissions WHERE submissions.submission_id='$mask5'");
$rows   = mysql_fetch_array($cat, MYSQL_ASSOC);
$array  = filter($rows['category']);
//Get Manufactuer ID
$man    = mysql_query("SELECT manufacturer_id FROM submissions WHERE submissions.submission_id='$mask5'");
$arows  = mysql_fetch_array($man, MYSQL_ASSOC);
$array1 = filter($arows['manufacturer_id']);
//Get All Submission ID's for this popup
$datum  = array();
$result = mysql_query("SELECT submission_id FROM submissions WHERE submissions.category='$array' AND submissions.manufacturer_id='$array1'");
while ($rowd = mysql_fetch_array($result, MYSQL_ASSOC)) {
    $datum[] = $rowd['submission_id'];
}
$datalist = implode($datum, ' , ');
$datalist = filter($datalist);
// Use Submission ID's to Get All Image ID's for this popup
$datum9   = array();
$datasql  = mysql_query("SELECT DISTINCT image_id FROM imagsub WHERE submission_id IN ($datalist)");
while ($row23 = mysql_fetch_array($datasql, MYSQL_ASSOC)) {
    $datum9[] = $row23['image_id'];
}
$datalist2 = implode($datum9, ' , ');
$datalist2 = filter($datalist2);
//Select filenames from images table that matches $datalist2 results
$sql = "SELECT * FROM images WHERE image_id IN ($datalist2)";
$resultz = mysql_query($sql);
?>
<html>
    <head>
    <title>Supplychex Vendor Dashboard</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    </head>
    <body onLoad="doInitGrid();" marginwidth="0"; topmargin="0">
      <div style="width:100%; height:120px; background-image:url(../images/header.png)">
        <div style="float:left; width:30%; text-align:center">
        <form action="../php/pop_category_viewimages.php" method="post" name="MyForm" target="_blank" id="MyForm">
          <fieldset>
          <legend>Attachments</legend>
            <SELECT id="dropdown" name="dropdown" style="width:250px">
              <?php
                while ( $rowg = mysql_fetch_array($resultz, MYSQL_ASSOC) ){ 
                    echo '<OPTION value="'.$rowg['image_id'].'">'.$rowg['filename'].'</OPTION>'."rn";
                 }
            ?>
            </SELECT></br></br>
            <INPUT type="SUBMIT" name="SUBMIT" value="View">
            </fieldset>
          </form>
        </div>
       </body>
</html>

我将此表单的此操作设置为此文件:

<?php
define("DB_HOST", ""); // set database host
define("DB_USER", ""); // set database user
define("DB_PASS", ""); // set database password
define("DB_NAME", ""); // set database name
$link = mysql_connect(DB_HOST, DB_USER, DB_PASS) or die("Couldn't make connection.");
$db = mysql_select_db(DB_NAME, $link) or die("Couldn't select database");
$id = $_POST['dropdown'];
$query  = sprintf('select * from images where image_id = %d', $id);
$result = mysql_query($query);
$image = mysql_fetch_array($result);
header('Content-type: ' . $image['mime_type']);
header('Content-length: ' . $image['file_size']);
echo $image['file_data'];
?> 

我目前在下拉列表中有一个gif文件和pdf文件。在所有浏览器中,gif和pdf在我的桌面上都能很好地工作。将打开一个新选项卡并显示其中一个。我刚买了一台新的笔记本电脑,尽管我在笔记本电脑上运行firefox 9,而不是简单地在新的选项卡中显示pdf,但浏览器会尝试下载pop_category_viewimages.php文件。在我笔记本电脑上的IE中,一个新的选项卡打开为空白。在我笔记本电脑上的chrome中,pdf打开得很好。gif在所有位置的所有浏览器中都可以正常打开。我完全被这件事弄糊涂了,希望我能在代码中调整一下,让pdf在所有浏览器中都能正确打开。

这意味着您没有安装PDF阅读器。Chrome是唯一一款内置PDF渲染器的浏览器(AFAIK)。其他浏览器将此任务委托给第三方软件,如Adobe的Acrobat Reader,后者提供插件,允许PDF直接在浏览器中呈现。由于缺少这些可用的插件,浏览器唯一知道该怎么做的就是提供文件供下载。

content-disposition标头设置为inline(要求浏览器显示)或attachment(要求浏览器将其下载到磁盘):

header('Content-Disposition: inline"');

header('Content-Disposition: attachment; filename="downloaded.pdf"');

php文件依赖于服务器,您可能需要配置IIS,或者安装wamp或example来获得您想要的功能。

相关内容