I have this form that pops up in a modal window like so:
<?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>
I have this action for this form set to this file:
<?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'];
?>
I currently have a gif file and pdf file in the dropdown. Both gif and pdf work great on my desktop in all browsers. A new tab opens and displays either one. I just picked up a new laptop and eventhough Im using firefox 9 in both places when I run this on my laptop instead of simply displaying the pdf in a new tab the browser tries to download the pop_category_viewimages.php file. In IE on my laptop a new tab opens up blank. In chrome on my laptop the pdf opens up just fine. The gif opens fine in all browsers in all locations. Im totally thrown by this and hoping there is something I can adjust in my code to have the pdf open correctly in all browsers.
It means you do not have a PDF reader installed. Chrome is the only browser (AFAIK) that has a PDF renderer built-in. Other browsers delegate this task to third party software like Adobe’s Acrobat Reader, which provide plugins that allow PDFs to be rendered directly in the browser. Lacking such available plugins, the only thing the browser knows what to do is to offer the file for download.