发布网友 发布时间:2022-04-06 04:10
共2个回答
热心网友 时间:2022-04-06 05:39
刚刚写好的,就是PHP保存图片到MYSQL数据库
<!--
CREATE TABLE ccs_image (
id int(4) unsigned NOT NULL auto_increment,
description varchar(250) default NULL,
bin_data longblob,
filename varchar(50) default NULL,
filesize varchar(50) default NULL,
filetype varchar(50) default NULL,
PRIMARY KEY (id)
)
-->
<HTML>
<HEAD>
<TITLE>
</TITLE></HEAD>
<BODY>
<?php
if (isset($_POST['submit'])) {
$form_description = $_POST['form_description'];
$form_data_name = $_FILES['form_data']['name'];
$form_data_size = $_FILES['form_data']['size'];
$form_data_type = $_FILES['form_data']['type'];
$form_data = $_FILES['form_data']['tmp_name'];
$connect = MYSQL_CONNECT( "localhost", "root","123456" ) or die("不能连接服务器");
mysql_select_db( image) or die("不能连接数据库");
$data = addslashes(fread(fopen($form_data, r), filesize($form_data)));
$result=MYSQL_QUERY("INSERT INTO ccs_image (description,bin_data,filename,filesize,filetype) VALUES ('$form_description','$data','$form_data_name','$form_data_size','$form_data_type')");
$id= mysql_insert_id();
MYSQL_CLOSE();
} else {
?>
<center>
<form method=post action=UPload.php enctype=multipart/form-data>
文件描述:
<br>
<input type=text name=form_description size=40>
<br>
<INPUT TYPE=hidden name=MAX_FILE_SIZE value=1000000>
<br>
<!--File to upload/store in database: -->
请选择上传文件:
<br>
<input type=file name=form_data size=40>
<br>
<input type=submit name=submit value=确定>
</form>
</center>
<?php
}
?>
</BODY>
</HTML>
热心网友 时间:2022-04-06 06:57
可以使用sql指令
create table iamges
(id int not null auto_increment primary key,
image_date blob
);
insert into images(image_data) values(Load_file("文件名“))