gpt4 book ai didi

php - 为什么有些图片不渲染

转载 作者:搜寻专家 更新时间:2023-10-31 22:07:18 24 4
gpt4 key购买 nike

我的程序使用 PHP 将各种大小的图像上传到 MySQL 数据库的 blob 字段中。我能够成功上传高达 1MB 及以上的不同大小。我的问题是,当我显示它们时,我能够显示小于 10KB 的图像。对于较大的图像,会显示错误..... 无法显示,因为它包含错误(在 Firefox 中),而在 Chrome 中,它只是显示一个图像占位符。我尝试了很多技巧,并且到处搜索。我编辑了 php.ini 和 my.ini。我的程序是一个内网应用,同时会有不到50个用户。这是用于显示图像的脚本:

如果我删除 header ('Content-Type: '.$resource_type),它会将二进制代码转储到屏幕上。我已将 MySQL 数据包大小增加到 100MB,但问题仍然存在。

    $d_id= $_GET['k'];$query="";$query_handle=0;$row="";$no_of_rows=0;
$query="SELECT * FROM tdoc ";
$query.=" WHERE ucase(trim(fsha_doc_key))='".strtoupper(trim($d_id))."' ";
$query_handle=mysql_query($query,$conn_handle);
if(!$query_handle) {$error_flag=1;echo '<br />Unable to execute query to Extract Resource CODE:FREF';}
if($query_handle) $no_of_rows=mysql_num_rows($query_handle);
if(($query_handle)&&($no_of_rows<=0)) {$error_flag=1;echo '<br />The Exact Resource: '.strip_tags($d_id).' NOT found ';}
if(($query_handle)&&($no_of_rows>0)){
$row=mysql_fetch_assoc($query_handle);
$resource_type=trim($row['ftype']);
$resource_size=$row['fsize'];
$resource_h=$row['fheight'];
$resource_w=$row['fwidth'];
$d_resource=$row['fdoc'];
header('Content-Type: '.$resource_type);
header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' );
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
header( 'Cache-Control: no-store, no-cache, must-revalidate' );
header( 'Cache-Control: post-check=0, pre-check=0', false );
header( 'Pragma: no-cache' );
header('Content-Length: '.filesize($d_resource));
header('Content-height: '.$resource_h);
header('Content-width: '.$resource_w);
echo stripslashes(base64_decode($d_resource));
}

我在这里专门阅读了有关此错误的帖子,但没有一个能解决我的具体问题,因为我的显示的是小尺寸图像,而不是 10kb 及以上的图像。 10kb 与我预计的稍后上传的平均图像大小相去甚远。请帮忙。

最佳答案

如果$d_resource是二值图像数据

你应该使用 imagejpeg 或 imagegif 或其他系列功能,而不是 echo

参见 Output image to browser or file - PHP

关于php - 为什么有些图片不渲染,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16632339/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com