Oracle数据库中表的结构
A VARCHAR2;
FILE BLOB;PHP 代码如下:
download.php:
<?php
if($_POST[action] == "download"){
if(count($_POST[chk]) <= 0)
echo "<script>alert('请选择记录');history.go(-1);</script>";
else
{
$file= $_POST[chk];
$f_conn = oci_connect( "geophys", "geophys","wjc", "UTF8");
for($i = 0; $i < count($file); $i++)
{
$sqlstr ="select * from LINE where LINE_ID = '".$file[$i]."'";
$parsed = oci_parse($f_conn, $sqlstr);
oci_execute($parsed) or die ("error:Unable to execute query\n");
if(OCIFetchinto($parsed,$result,OCI_ASSOC+OCI_RETURN_LOBS))
{
header("Content-type: text/plain");//纯文本格式
header("Content-Disposition: attachment; filename=".$result[FILE]);
readfile($result[FILE]);
}
oci_free_statement($parsed);
}
oci_close($f_conn);
}
}
?>
结果,仅在页面中显示如下内容(没出现下载界面),那位高手帮看一下,谢谢,最好是告诉俺怎么把查询到得多个文件一块打包下载的方法
<br />
<b>Warning</b>: Header may not contain more than a single header, new line detected. in <b>C:\ms4w\apps\qqt\download.php</b> on line <b>17</b><br />
<br />
<b>Warning</b>: readfile(DW02-15 ,1, 2008/06/02 8:24:18, 122.370420, 37.739392
DW02-15 ,2, 2008/06/02 8:24:24, 122.370246, 37.739669
DW02-15 ,3, 2008/06/02 8:24:30, 122.370064, 37.739946
DW02-15 ,4, 2008/06/02 8:24:36, 122.369876, 37.740222
DW02-15 ,5, 2008/06/02 8:24:42, 122.369681, 37.740498
DW02-15 ,6, 2008/06/02 8:24:48, 122.369480, 37.740772
DW02-15 ,7, 2008/06/02 8:24:54, 122.369273, 37.741046
DW02-15 ,8, 2008/06/02 8:25:00, 122.369060, 37.741318
DW02-15 ,9, 2008/06/02 8:25:06, 122.368841, 37.741590
DW02-15 ,10, 2008/06/02 8:25:12, 122.368618, 37.741860
DW02-15 ,11, 2008/06/02 8:25:18, 122.368390, 37.742129
DW02-15 ,12, 2008/06/02 8:25:24, 122.368157, 37.742398
DW02-15 ,13, 2008/06/02 8:25:30, 122.367920, 37.742665
DW02-15 ,14, 2008/06/02 8:25:36, 122.367678, 37.742932
DW02-15 ,15, 2008/06/02 8:25:42, 122.367432, 37.743197
DW02-15 ,16, 2008/06/02 8:25:48, 122.367183, 37.743463
DW02-15 ,17, 2008/06/02 8:25:54, 122.366931, 37.743727
DW02-15 ,18, 2008/06/02 8:26:00, 122.366677, 37.743992 in <b>C:\ms4w\apps\qqt\download.php</b> on line <b>18</b><br />
A VARCHAR2;
FILE BLOB;PHP 代码如下:
download.php:
<?php
if($_POST[action] == "download"){
if(count($_POST[chk]) <= 0)
echo "<script>alert('请选择记录');history.go(-1);</script>";
else
{
$file= $_POST[chk];
$f_conn = oci_connect( "geophys", "geophys","wjc", "UTF8");
for($i = 0; $i < count($file); $i++)
{
$sqlstr ="select * from LINE where LINE_ID = '".$file[$i]."'";
$parsed = oci_parse($f_conn, $sqlstr);
oci_execute($parsed) or die ("error:Unable to execute query\n");
if(OCIFetchinto($parsed,$result,OCI_ASSOC+OCI_RETURN_LOBS))
{
header("Content-type: text/plain");//纯文本格式
header("Content-Disposition: attachment; filename=".$result[FILE]);
readfile($result[FILE]);
}
oci_free_statement($parsed);
}
oci_close($f_conn);
}
}
?>
结果,仅在页面中显示如下内容(没出现下载界面),那位高手帮看一下,谢谢,最好是告诉俺怎么把查询到得多个文件一块打包下载的方法
<br />
<b>Warning</b>: Header may not contain more than a single header, new line detected. in <b>C:\ms4w\apps\qqt\download.php</b> on line <b>17</b><br />
<br />
<b>Warning</b>: readfile(DW02-15 ,1, 2008/06/02 8:24:18, 122.370420, 37.739392
DW02-15 ,2, 2008/06/02 8:24:24, 122.370246, 37.739669
DW02-15 ,3, 2008/06/02 8:24:30, 122.370064, 37.739946
DW02-15 ,4, 2008/06/02 8:24:36, 122.369876, 37.740222
DW02-15 ,5, 2008/06/02 8:24:42, 122.369681, 37.740498
DW02-15 ,6, 2008/06/02 8:24:48, 122.369480, 37.740772
DW02-15 ,7, 2008/06/02 8:24:54, 122.369273, 37.741046
DW02-15 ,8, 2008/06/02 8:25:00, 122.369060, 37.741318
DW02-15 ,9, 2008/06/02 8:25:06, 122.368841, 37.741590
DW02-15 ,10, 2008/06/02 8:25:12, 122.368618, 37.741860
DW02-15 ,11, 2008/06/02 8:25:18, 122.368390, 37.742129
DW02-15 ,12, 2008/06/02 8:25:24, 122.368157, 37.742398
DW02-15 ,13, 2008/06/02 8:25:30, 122.367920, 37.742665
DW02-15 ,14, 2008/06/02 8:25:36, 122.367678, 37.742932
DW02-15 ,15, 2008/06/02 8:25:42, 122.367432, 37.743197
DW02-15 ,16, 2008/06/02 8:25:48, 122.367183, 37.743463
DW02-15 ,17, 2008/06/02 8:25:54, 122.366931, 37.743727
DW02-15 ,18, 2008/06/02 8:26:00, 122.366677, 37.743992 in <b>C:\ms4w\apps\qqt\download.php</b> on line <b>18</b><br />
header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, max-age=0, no-cache, must-revalidate'); // HTTP/1.1
header('Cache-Control: post-check=0, pre-check=0', false);
header('Cache-Control: private');
header('Content-Transfer-Encoding: none');
header('Content-Disposition: attachment; filename='.$filename.'');
//header('Content-Type: application/vnd.ms-excel; name="'.$filename.'"');
echo $str;
//$filepath-文件路径//$filename文件名
function file_down($filepath, $filename = '')
{
if(!$filename) $filename = basename($filepath);
$fileinfo = pathinfo($filename);
$filetype = $fileinfo['extension'];
if(ob_get_length() !== false) @ob_end_clean();
header('Pragma: public');
header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: pre-check=0, post-check=0, max-age=0');
header('Content-Transfer-Encoding: binary');
header('Content-Encoding: none');
header('Content-type: '.$filetype);
header('Content-Disposition: attachment; filename="'.$filename.'"');
readfile($filepath);
exit;
}
header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, max-age=0, no-cache, must-revalidate'); // HTTP/1.1
header('Cache-Control: post-check=0, pre-check=0', false);
header('Cache-Control: private');
header('Content-Transfer-Encoding: none');
header('Content-Disposition: attachment; filename='.$filename.'');
//header('Content-Type: application/vnd.ms-excel; name="'.$filename.'"');
echo $str;
<?php
$file= $_POST[chk];
$f_conn = oci_connect( "geophys", "geophys","wjc", "UTF8");
for($i = 0; $i < count($file); $i++)
{
$sqlstr ="select * from LINE where LINE_ID = '".$file[$i]."'";
$parsed = oci_parse($f_conn, $sqlstr);
oci_execute($parsed) or die ("Unable to execute query\n");
if(OCIFetchinto($parsed,$row,OCI_ASSOC+OCI_RETURN_LOBS))
{
header("Content-type: text/plain");
header("Content-Disposition: attachment; filename=".$row['FILE_NAME']);
echo $row[FILE];
}
oci_free_statement($parsed);
}
oci_close($f_conn);
?>