主题:为什么把图片存入数据库不成功能呢?
我上传图片到数据库用了4个文件
---- 文件upfile.htm --- 文件上传界面
<form method='post' action='upfile.php' enctype='multipart/form-data'>
文件描述:
<input type='text' name='description' size='40'>
<INPUT TYPE='hidden' name='MAX_FILE_SIZE' value='1000000'>
保存文件:
<input type='file' name='up_file' size='40'>
<p><input type='submit' name='submit' value='submit'>
</form>
---- 文件upfile.php --- 文件上传过程
<?
include "common.php"
$lgx=new db_mysql;
$lgx->connect();
$data = addslashes(fread(fopen($up_file, "r"), filesize($up_file)));
echo $description;
echo $MAX_FILE_SIZE;
$str=" INSERT INTO binary_data(description,bin_data,filename,filesize,filetype) VALUES('$description','$data','$up_file_name','$up_file_size','$up_file_type')";
$result=$lgx->query($str);
$id= mysql_insert_id();
print "<p>This file has the following Database ID: <b>$id</b>"; //显示文件在数据库中的ID
$lgx->close();
?>
-- getdata.php --
<?php
$dbhost="localhost"; //主机名
$dbuser="root"; //数据库用户名
$dbpasswd=""; //相应的数据库密码
$dbname="a";
@MYSQL_CONNECT($dbhost,$dbuser,$dbpasswd);
@mysql_select_db( $dbname);
$query = "select bin_data,filetype from binary_data where id=4";
$result = @MYSQL_QUERY($query);
$data = @MYSQL_RESULT($result,0, "bin_data");
$type = @MYSQL_RESULT($result,0, "filetype");
Header( "Content-type: $type");
echo $data;
?>
-- listphoto.php --
<img src="getdata.php">
不知道怎么搞的,就是显示不出来
---- 文件upfile.htm --- 文件上传界面
<form method='post' action='upfile.php' enctype='multipart/form-data'>
文件描述:
<input type='text' name='description' size='40'>
<INPUT TYPE='hidden' name='MAX_FILE_SIZE' value='1000000'>
保存文件:
<input type='file' name='up_file' size='40'>
<p><input type='submit' name='submit' value='submit'>
</form>
---- 文件upfile.php --- 文件上传过程
<?
include "common.php"
$lgx=new db_mysql;
$lgx->connect();
$data = addslashes(fread(fopen($up_file, "r"), filesize($up_file)));
echo $description;
echo $MAX_FILE_SIZE;
$str=" INSERT INTO binary_data(description,bin_data,filename,filesize,filetype) VALUES('$description','$data','$up_file_name','$up_file_size','$up_file_type')";
$result=$lgx->query($str);
$id= mysql_insert_id();
print "<p>This file has the following Database ID: <b>$id</b>"; //显示文件在数据库中的ID
$lgx->close();
?>
-- getdata.php --
<?php
$dbhost="localhost"; //主机名
$dbuser="root"; //数据库用户名
$dbpasswd=""; //相应的数据库密码
$dbname="a";
@MYSQL_CONNECT($dbhost,$dbuser,$dbpasswd);
@mysql_select_db( $dbname);
$query = "select bin_data,filetype from binary_data where id=4";
$result = @MYSQL_QUERY($query);
$data = @MYSQL_RESULT($result,0, "bin_data");
$type = @MYSQL_RESULT($result,0, "filetype");
Header( "Content-type: $type");
echo $data;
?>
-- listphoto.php --
<img src="getdata.php">
不知道怎么搞的,就是显示不出来