从数据库提供图形 [英] Serving graphics from a database
问题描述
我想将经常使用的图形元素存储在数据库中,并从那里而不是从文件系统中提供它们。
有没有更好的/更快的方式来做到这一点? (错误检查
等未显示)
页面的相关部分:
<?php
echo
''< table>< tr>< td>
< img src =" ImageFromDB.php?Image = ImageIdentifer" >
< / td>< / tr>< / table>'';
?>
ImageFromDB.php:
<?php
$ imgname = $ _GET [''Image''];
$ dset = mysql_query (''SELECT imagebits FROM graphics_table
WHERE name ="''。$ imgname。''"'');
$ rec = mysql_fetch_row($ dset) ;
$ browser = fopen(''php:// output'',''w'');
header(''Content-Type:image / png '');
fwrite($ browser,$ rec [0]);
?>
我通过文档并做了一些谷歌搜索,但没有找到
任何明显有用的东西。非常感谢任何见解。
玛格丽特
-
(要给我发邮件,请将.not.invalid更改为。 net,first。
不便之处。)
imgname =
< blockquote> _GET [''Image''];
dset = mysql_query(''SELECT imagebits FROM graphics_table
WHERE name ="' '。
I want to store frequently-used graphic elements in a db and serve
them from there rather than from the filesystem.
Is there a better/faster way to do that than this? (error checking
etc not shown)
The relevant piece of the page:
<?php
echo
''<table><tr><td>
<img src="ImageFromDB.php?Image=ImageIdentifer">
</td></tr></table>'' ;
?>
ImageFromDB.php:
<?php
$imgname = $_GET[''Image''] ;
$dset = mysql_query( ''SELECT imagebits FROM graphics_table
WHERE name="'' . $imgname . ''"'' ) ;
$rec = mysql_fetch_row($dset) ;
$browser = fopen( ''php://output'', ''w'') ;
header( ''Content-Type: image/png'' ) ;
fwrite( $browser, $rec[0] ) ;
?>
I fingered through the docs and did some googling, but didn''t find
anything obviously helpful. Many thanks for any insights.
Margaret
--
(To mail me, please change .not.invalid to .net, first.
Apologies for the inconvenience.)
imgname =
_GET[''Image''] ;
dset = mysql_query( ''SELECT imagebits FROM graphics_table
WHERE name="'' .
这篇关于从数据库提供图形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!