duanfan1869
duanfan1869
2013-11-16 05:24

在PHP中通过ODBC从Access获取二进制文件仅返回前4 KB

已采纳

I am trying to use PHP (CodeIgniter) and ODBC to fetch files (image, pdf, doc) stored in an Access database and show them in a browser. Unfortunately it returns only the first 4kb of every file.

$this->load->database();
$query = $this->db->query("select  noe,file from Sanad_File
where id=$id");
$rowim=$query->result();
if($rowim[0]->noe=="pdf")
  header('Content-Type: application/pdf');
else if ($rowim[0]->noe=="jpg") 
  header('Content-Type: image/jpeg');
else if ($rowim[0]->noe=="tif") 
header('Content-Type: image/tiff');
else if ($rowim[0]->noe=="doc" || $rowim[0]->noe=="docx")   
header('Content-Type: application/msword');
echo $rowim[0]->file;

I suspect that it's an ODBC issue. Can anyone help me find the solution?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • douduiwei2831 douduiwei2831 8年前

    The default value for longreadlen is 4096 (ref: here). You will need to increase that value via odbc_longreadlen().

    点赞 评论 复制链接分享