怎样将一个图像文件插入到数据库中阿
能否详细给个例子阿 问题点数:100、回复次数:6Top
1 楼zhc168(上泉潮)回复于 2004-09-03 20:49:34 得分 20
<form name=form1 enctype="multipart/form-data" action="post_RenYuan_pic.asp" method=post onsubmit="return mysubmit(this)">
<input type="file" name="imgFile" onchange="return PreViewPic()" style="font-size:9pt" ACCEPT="image/gif,image/jpg" size="20" class="tx1">
<input type="submit" value=" 上传..." name="B3" style="border:1px double rgb(88,88,88);font:9pt">
</form>
<Script language="javascript">
function mysubmit(theform)
{
if(theform.imgFile.value=="")
{
alert("请点击浏览按钮,选择您要上传的JPEG或GIF照片!")
theform.imgFile.focus();
return (false);
}
else
{
str= theform.imgFile.value;
strs=str.toLowerCase();
lens=strs.length;
extname=strs.substring(lens-4,lens);
if(extname!=".jpg" && extname!=".gif" && extname!=".bmp")
{
alert("请选择JPEG或gif文件!\r\n扩展名:jpg,gif,bmp");
theform.imgFile.focus();
return (false);
}
}
return (true);
}
</script>
Top
2 楼zhc168(上泉潮)回复于 2004-09-03 20:51:00 得分 15
<%
imgdata=Fields("imgFile").Value
Set Rec = Server.CreateObject("ADODB.Recordset")
Rec.Open "SELECT * FROM RenYuan WHERE ID="&ID&"",Conn,1,3
if Rec.RecordCount <> 0 then
ID = Rec("ID")
Rec("PHOTO").appendchunk imgdata
Rec.update
end if
Rec.close
Call CloseDatabase() '关闭数据库对象
set Rec=nothing
%>
Top
3 楼dsclub(任搏软)回复于 2004-09-03 20:52:26 得分 15
http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=178193Top
4 楼dsclub(任搏软)回复于 2004-09-03 20:53:12 得分 20
http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=169166Top
5 楼liuxiaoyi666(MSMVP 小猪妹荣誉马甲之八卦兔子)回复于 2004-09-03 20:59:25 得分 20
下载个lyfuploadTop
6 楼wgb219(wgb)回复于 2004-09-03 21:38:41 得分 10
为什么非要把图片存进数据库呢?存个路径多方便啊????Top




