多谢各位!! 但我在实现上述功能的时侯,只要是小于1K的图片就能在数据库中读出来,并完整的在IE中显示。 这是我写的,欢迎指正: <?php MYSQL_CONNECT("localhost","root","gogogo"); MySQL_select_db("binary_data"); $data =addslashes(fread(fopen('sun.gif',"r"), filesize('sun.gif'))); $result=MYSQL_QUERY("INSERT INTO binary_data (bin_data,filename,filesize,filetype)VALUES ('$data','$form_data_name','$form_data_size','$form_data_type')"); $id= MySQL_insert_id(); print "This file has the following Database ID: $id"; ?><?phpMYSQL_CONNECT("localhost","root","gogogo"); MySQL_select_db("binary_data"); $query ="select bin_data from binary_data where id=45"; $result = @MYSQL_QUERY($query); $data = @MYSQL_RESULT($result,0,"bin_data"); ?><?php require('show.php'); Header("Content-type:image/gif"); echo $data; ?> 下面是我的my.ini #This File was made using the WinMySQLAdmin 1.4 Tool #2002-9-4 22:10:13#Uncomment or Add only the keys that you know how works. #Read the MySQL Manual for instructions[mysqld] basedir=c:/mysql #bind-address=127.0.0.1 datadir=c:/mysql/data #language=c:/mysql/share/your language directory #slow query log#= #tmpdir#= #port=3306 set-variable=key_buffer=16M set-variable = max_allowed_packet = 8M set-variable = select_limit = 8M [WinMySQLadmin] Server=C:/mysql/bin/mysqld-nt.exe user=root password=gogogo
什么叫数据包?MySQL一次进行吞吐的数据的最大容量,如果>8M,将分多次进行写入和读出,不是指总的大小。再说8M和1K,天壤之别!肯定是你对数据库进行操作的时候有问题,检查你的代码吧。
但我在实现上述功能的时侯,只要是小于1K的图片就能在数据库中读出来,并完整的在IE中显示。
这是我写的,欢迎指正:
<?php
MYSQL_CONNECT("localhost","root","gogogo");
MySQL_select_db("binary_data");
$data =addslashes(fread(fopen('sun.gif',"r"), filesize('sun.gif')));
$result=MYSQL_QUERY("INSERT INTO binary_data (bin_data,filename,filesize,filetype)VALUES ('$data','$form_data_name','$form_data_size','$form_data_type')");
$id= MySQL_insert_id();
print "This file has the following Database ID: $id";
?><?phpMYSQL_CONNECT("localhost","root","gogogo");
MySQL_select_db("binary_data");
$query ="select bin_data from binary_data where id=45";
$result = @MYSQL_QUERY($query);
$data = @MYSQL_RESULT($result,0,"bin_data");
?><?php
require('show.php');
Header("Content-type:image/gif"); echo $data;
?>
下面是我的my.ini
#This File was made using the WinMySQLAdmin 1.4 Tool
#2002-9-4 22:10:13#Uncomment or Add only the keys that you know how works.
#Read the MySQL Manual for instructions[mysqld]
basedir=c:/mysql
#bind-address=127.0.0.1
datadir=c:/mysql/data
#language=c:/mysql/share/your language directory
#slow query log#=
#tmpdir#=
#port=3306
set-variable=key_buffer=16M
set-variable = max_allowed_packet = 8M
set-variable = select_limit = 8M
[WinMySQLadmin]
Server=C:/mysql/bin/mysqld-nt.exe
user=root
password=gogogo