本文介绍了从MSSQL DB检索的图像文件中缺少部分数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试显示保存在图像字段中的数据库中的图像.但是我只能看到63KB的图像.

I'm trying to show image from DB saved in Image field. But I can see only 63KB of image.

这是我的代码:

$sql='SELECT Photo FROM Personel WHERE ID_USER = '.$id;

$result=mssql_query($sql);

$res=mssql_fetch_assoc($result);

header('Content-type:image/jpeg');
echo$res['Photo'];

如您所见,没有什么特别的,所以我认为数据库或服务器配置存在问题.

As you can see nothing special, so I think problem in DB or server configuration.

在Windows XP服务器上安装的数据库.

DB installed on Windows XP server.

实际上是访问控制系统数据库和安装在该程序文件夹中的SQL文件,但不知道此信息是否有用.

Actually it's Access control systems DB, and SQL files installed in that program's folder, but don't know this information useful or not.

有什么主意吗?

更新照片"字段类型的屏幕截图:

UPDATEScreenshot for Photo field type:

推荐答案

鉴于您的评论说整个图像 都存储在数据库中,该问题与PHP和/或Web服务器中的数据限制/超时有关.

Given that your comments say that the entire image is being stored in the DB, it's possible that the issue is related to a data limit / timeout within PHP and / or the webserver.

我在此处留下了答案的以下部分以获取历史信息(以展示我们尝试的其他内容),但是请查看以下评论​​,因为该问题更有可能与PHP或网络服务器配置设置有关,限制了响应数据的大小.仍未完全解决.

I've left the following part of the answer here for historic info (to show what else we tried) but please see the comments below, as it's more likely that the issue is related to a PHP or webserver config setting, limiting the size of the response data. Still not fully resolved yet.

我注意到您有一个 Content-type 标头,但没有一个 Content-length 标头.

I notice you have a Content-type header, but not a Content-length header.

您可以尝试添加带有某些任意已知值(例如12288)的 Content-length 标头,并查看这是否会影响返回的文件大小(因为您知道当前的大小为63K-变成12K?)

You could try adding a Content-length header with some arbitrary, known value (e.g. 12288) and see if this affects the size of the file returned (since you know that it's currently 63K - does it change to 12K?)

如果这样做,那么您将需要PHP来计算/找出图像的实际大小,并添加一个具有该长度的Content-length标头.

If it does, then you'll need to get PHP to calculate / find out the actual size of your image and add a Content-length header of that length.

这篇关于从MSSQL DB检索的图像文件中缺少部分数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 02:36