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

时间:2012-01-26 01:08:32

标签: php browser

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

<?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>'."\r\n";
                 }
            ?>
            </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。

3 个答案:

答案 0 :(得分:2)

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

答案 1 :(得分:1)

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

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

或者

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

答案 2 :(得分:0)

php文件取决于服务器,您可能需要配置IIS,或者安装wamp或xamp以获得您要查找的功能。