13 个解决方案
#1
关注中,我也有此同类问题
#2
什么错?
#3
<!--#include file="inc/ConnectDatabase.inc"-->
<!--#include file="inc/js_.inc"-->
<!--#include virtual="inc/TurnPage.inc"-->
<%
dim sql
sql = "select * from jianjie order by id desc"
set rs = server.CreateObject("adodb.recordset")
rs.Open sql,objconn,1,1
%>
<head>
<title>商家修改</title>
<link rel="stylesheet" href="css/css.css" type="text/css">
<script language=javascript>
function mOvr(src,clrOver)
{ if (!src.contains(event.fromElement))
{ src.style.cursor = 'hand'; src.bgColor = clrOver; }
}
function mOut(src,clrIn)
{ if (!src.contains(event.toElement))
{ src.style.cursor = 'default'; src.bgColor = clrIn; }
}
function mClk(src)
{ if(event.srcElement.tagName=='TD')
{src.children.tags('A')[0].click();}
}
function modi(id,name){
window.open("xx2.asp?id="+id+"&name="+name,"xxrl","top=160,left=200,width=370,height=250");
}
function show(id){
window.open("colist.asp?id="+id,"xxrl","top=50,left=40,width=664,height=440");
}
</script>
</head>
<body topmargin="0" leftmargin="0">
<div align="center">
<center>
<table border="0" width="650" cellspacing="0" cellpadding="0" ID="Table1">
<tr>
<td bgcolor="#D6DEF3" width="655"> <p align="left">富贵园后台程序商家修改</p></td>
<td bgcolor="#F8E0D8" width="655" > </td>
</tr>
<tr>
<td align="center" width="655" bgcolor="#FFFFFF" height="10" valign="middle" colspan="2">
<%
dim RowCount
RowCount = 10
call TurnPage(rs,RowCount)
%>
</td>
</tr>
<tr>
<td align="center" width="655" bgcolor="#FFFFFF" valign="top" colspan="2">
<div align="left">
<table width="650" border="0" cellspacing="1" cellpadding="1" class="hello1" id="Table2">
<tr>
<td width="68" align="center" bgcolor="#D4D4D4">商家名称</td>
<td width="166" align="center" bgcolor="#D4D4D4">商家地址</td>
<td width="96" align="center" bgcolor="#D4D4D4">商家电话</td>
<td width="92" align="center" bgcolor="#D4D4D4">商家传真</td>
<td width="69" align="center" bgcolor="#D4D4D4">营业时间</td>
<td align="center" width="69" bgcolor="#D4D4D4">详细资料</td>
<td align="center" width="66" bgcolor="#D4D4D4">修改</td>
</tr>
<%while not rs.EOF and RowCount>0%>
<tr bgcolor="#FDF2FB" onMouseOver="mOvr(this,'#B4DEDE');" onMouseOut="mOut(this,'#FDF2FB');" class="hello1">
<td width="68" align="center"><%=trim(rs("name"))%></td>
<td width="166" align="center"><%=trim(rs("address"))%></td>
<td width="96" align="center"><%=trim(rs("tel"))%></td>
<td align="center" width="92"><%=trim(rs("fax"))%> </td>
<td align="center" width="69"><%=trim(rs("yydata"))%></td>
<td align="center" width="69"><a href="javascript:show(<%=trim(rs("id"))%>);"><img border="0" src="images/xx.gif" width="20" height="18"></a></td>
<td align="center" width="66"><a href="javascript:modi(<%=trim(rs("id"))%>,'<%=trim(rs("name"))%>');"><img src="images/modi.gif" width="25" height="21" border="0"></a></td>
</tr>
<%
RowCount = RowCount-1
rs.MoveNext
wend
rs.Close
objconn.close
%>
</table>
</div></td>
</tr>
</table>
</center>
</div>
<p align="center">
<p>
<!--#include file="inc/js_.inc"-->
<!--#include virtual="inc/TurnPage.inc"-->
<%
dim sql
sql = "select * from jianjie order by id desc"
set rs = server.CreateObject("adodb.recordset")
rs.Open sql,objconn,1,1
%>
<head>
<title>商家修改</title>
<link rel="stylesheet" href="css/css.css" type="text/css">
<script language=javascript>
function mOvr(src,clrOver)
{ if (!src.contains(event.fromElement))
{ src.style.cursor = 'hand'; src.bgColor = clrOver; }
}
function mOut(src,clrIn)
{ if (!src.contains(event.toElement))
{ src.style.cursor = 'default'; src.bgColor = clrIn; }
}
function mClk(src)
{ if(event.srcElement.tagName=='TD')
{src.children.tags('A')[0].click();}
}
function modi(id,name){
window.open("xx2.asp?id="+id+"&name="+name,"xxrl","top=160,left=200,width=370,height=250");
}
function show(id){
window.open("colist.asp?id="+id,"xxrl","top=50,left=40,width=664,height=440");
}
</script>
</head>
<body topmargin="0" leftmargin="0">
<div align="center">
<center>
<table border="0" width="650" cellspacing="0" cellpadding="0" ID="Table1">
<tr>
<td bgcolor="#D6DEF3" width="655"> <p align="left">富贵园后台程序商家修改</p></td>
<td bgcolor="#F8E0D8" width="655" > </td>
</tr>
<tr>
<td align="center" width="655" bgcolor="#FFFFFF" height="10" valign="middle" colspan="2">
<%
dim RowCount
RowCount = 10
call TurnPage(rs,RowCount)
%>
</td>
</tr>
<tr>
<td align="center" width="655" bgcolor="#FFFFFF" valign="top" colspan="2">
<div align="left">
<table width="650" border="0" cellspacing="1" cellpadding="1" class="hello1" id="Table2">
<tr>
<td width="68" align="center" bgcolor="#D4D4D4">商家名称</td>
<td width="166" align="center" bgcolor="#D4D4D4">商家地址</td>
<td width="96" align="center" bgcolor="#D4D4D4">商家电话</td>
<td width="92" align="center" bgcolor="#D4D4D4">商家传真</td>
<td width="69" align="center" bgcolor="#D4D4D4">营业时间</td>
<td align="center" width="69" bgcolor="#D4D4D4">详细资料</td>
<td align="center" width="66" bgcolor="#D4D4D4">修改</td>
</tr>
<%while not rs.EOF and RowCount>0%>
<tr bgcolor="#FDF2FB" onMouseOver="mOvr(this,'#B4DEDE');" onMouseOut="mOut(this,'#FDF2FB');" class="hello1">
<td width="68" align="center"><%=trim(rs("name"))%></td>
<td width="166" align="center"><%=trim(rs("address"))%></td>
<td width="96" align="center"><%=trim(rs("tel"))%></td>
<td align="center" width="92"><%=trim(rs("fax"))%> </td>
<td align="center" width="69"><%=trim(rs("yydata"))%></td>
<td align="center" width="69"><a href="javascript:show(<%=trim(rs("id"))%>);"><img border="0" src="images/xx.gif" width="20" height="18"></a></td>
<td align="center" width="66"><a href="javascript:modi(<%=trim(rs("id"))%>,'<%=trim(rs("name"))%>');"><img src="images/modi.gif" width="25" height="21" border="0"></a></td>
</tr>
<%
RowCount = RowCount-1
rs.MoveNext
wend
rs.Close
objconn.close
%>
</table>
</div></td>
</tr>
</table>
</center>
</div>
<p align="center">
<p>
#4
显示选中的记录页<!--#include file="inc/ConnectDatabase.inc"-->
<%
dim id1,name1
id1=trim(request("id"))
name1=trim(request("name"))
dim sql_
sql_="select * from jianjie where id='"&id1&"' and name='"&name1&"'"
set rs_ = server.CreateObject("adodb.recordset")
rs_.open sql_,objconn,1,1
if rs_.recordcount<=0 then
rs_.close
'objconn.close
alert_error("数据异常!")
response.end
else
%>
<html>
<head>
<title>增加商家</title>
<link href="index.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<p align="center" class="one"><br>
修改———主力商家
<link href="index.css" rel="stylesheet" type="text/css">
<form enctype="multipart/form-data" method="post" action="xx3.asp">
<table width="86%" border="0" cellspacing="1" cellpadding="4" align="center" bordercolor="#333333">
<tr bgcolor="#FFCC66">
<td width="32%" height="29" bgcolor="#FFFFFF"> </td>
<td width="68%" bgcolor="#FFFFFF">商家名称:
<input name="nn" type="text" id="nn" value="<%=trim(rs_("name"))%>" size="40"> <br>
商家简介:
<textarea name="dd" cols="40" id="dd"><%=trim(rs_("description"))%></textarea> <br> <span class="one">商家地址:</span>
<input name="aa" type="text" id="aa" value="<%=trim(rs_("address"))%>" size="40"> <br>
联系电话:
<input name="tt" type="text" id="tt" value="<%=trim(rs_("tel"))%>" size="40"> <br>
传 真:
<input name="ff" type="text" id="ff" value="<%=trim(rs_("fax"))%>" size="40"> <br>
营业时间:
<input name="yy" type="text" id="yy" value="<%=trim(rs_("yydata"))%>" size="40"> <br>
店铺简图: <img src="<%=rs_("logo")%>" width="108" height="32" border="0"><br>
<input name="logo" type="file" id="logo"> <br> <br>
<input type="submit" name="Submit" value="增加"> </td>
</tr>
</table>
</form>
<%
end if
%>
<%
dim id1,name1
id1=trim(request("id"))
name1=trim(request("name"))
dim sql_
sql_="select * from jianjie where id='"&id1&"' and name='"&name1&"'"
set rs_ = server.CreateObject("adodb.recordset")
rs_.open sql_,objconn,1,1
if rs_.recordcount<=0 then
rs_.close
'objconn.close
alert_error("数据异常!")
response.end
else
%>
<html>
<head>
<title>增加商家</title>
<link href="index.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<p align="center" class="one"><br>
修改———主力商家
<link href="index.css" rel="stylesheet" type="text/css">
<form enctype="multipart/form-data" method="post" action="xx3.asp">
<table width="86%" border="0" cellspacing="1" cellpadding="4" align="center" bordercolor="#333333">
<tr bgcolor="#FFCC66">
<td width="32%" height="29" bgcolor="#FFFFFF"> </td>
<td width="68%" bgcolor="#FFFFFF">商家名称:
<input name="nn" type="text" id="nn" value="<%=trim(rs_("name"))%>" size="40"> <br>
商家简介:
<textarea name="dd" cols="40" id="dd"><%=trim(rs_("description"))%></textarea> <br> <span class="one">商家地址:</span>
<input name="aa" type="text" id="aa" value="<%=trim(rs_("address"))%>" size="40"> <br>
联系电话:
<input name="tt" type="text" id="tt" value="<%=trim(rs_("tel"))%>" size="40"> <br>
传 真:
<input name="ff" type="text" id="ff" value="<%=trim(rs_("fax"))%>" size="40"> <br>
营业时间:
<input name="yy" type="text" id="yy" value="<%=trim(rs_("yydata"))%>" size="40"> <br>
店铺简图: <img src="<%=rs_("logo")%>" width="108" height="32" border="0"><br>
<input name="logo" type="file" id="logo"> <br> <br>
<input type="submit" name="Submit" value="增加"> </td>
</tr>
</table>
</form>
<%
end if
%>
#5
修改的时候,先把图片路径读出来,根据路径显示图片。如果需要修改图片,那么就要在另一个文件处理。一般情况,上传图片时传递的是二进制数据。而通过表单提交传递的数据却不是。
注意:上传图片时的表单 ,的enctype值。
<form action="" method="post" enctype="multipart/form-data">
</form>
不过,我曾经在csdn好象看到过关于图片和图片信息同时提交的方法,你找找吧,我不记得在哪了?如果允许,还是建议你分开处理。
注意:上传图片时的表单 ,的enctype值。
<form action="" method="post" enctype="multipart/form-data">
</form>
不过,我曾经在csdn好象看到过关于图片和图片信息同时提交的方法,你找找吧,我不记得在哪了?如果允许,还是建议你分开处理。
#6
上传要修改的图片,文件名为要更改的图片的文件名。
不就行了么?
不就行了么?
#7
<!--#include file="inc/ConnectDatabase.inc"-->
<!--#include file="inc/cls_load.inc"-->
<!--#include file="inc/js_.inc"-->
<%
dim upload,upfile,sql
dim fromnn,fromdd,fromaa,fromtt,fromff,fromyy
set upload=new upload_5xSoft ''建立上传对象
'userid = session("userid")
'下面是获取前一页面中的input元素的方法,用upload.form来获取,相当于asp中的request.form
fromnn = upload.form("nn")
fromdd = upload.form("dd")
fromaa = upload.form("aa")
fromtt = upload.form("tt")
fromff = upload.form("ff")
fromyy = upload.form("yy")
set upload=new upload_5xsoft
'下面是用file对象来存储上一页面中的file控件的图片值,其中包括图片的路径,大小等等
set upfile=upload.file("logo")
if upfile.FileSize>0 then
if GetExtendName(upfile.FileName)<>"swf" and GetExtendName(upfile.FileName)<>"jpg" and GetExtendName(upfile.FileName)<>"gif" then
response.redirect("result.asp?msg=不是正确的图片格式。")
end if
end if
'sql="SELECT TOP 1 id,name,logo,description,address,tel,fax,yydata FROM jianjie order by id desc"
set rs=server.createobject("adodb.recordset")
rs.Open sql,objconn,1,2
while not rs.EOF
if trim(fromnn) = trim(rs("name")) then
rs.Close
'CloseConnection(objconn)
Alert_Back("此商家已经存在,请重新输入!")
Response.End
end if
rs.MoveNext
wend
'rs.addnew
rs("name")=fromnn
rs("description")=fromdd
rs("address")=fromaa
rs("tel")=fromtt
rs("fax")=fromff
rs("yydata")=fromyy
rs.update
rs.close()
rs.open sql,objconn,1,2
'response.write rs("id")
'response.End()
if upfile.FileSize>0 then
upfile.SaveAs Server.mappath("images/image"&rs("id")&"."&GetExtendName(upfile.FileName))
rs("logo") = "images/"&"image"&rs("id")&"."&GetExtendName(upfile.FileName)
rs.update
end if
'rs.close
'objconn.execute "insert into company (name,description) values('"&fromnn&"','"&fromdd&"')"
'objconn.close
'rs.close
response.Redirect("x1.asp")
function GetExtendName(FileName)//获取扩展名
dim ExtName
ExtName = LCase(FileName)
ExtName = right(ExtName,3)
ExtName = right(ExtName,3-Instr(ExtName,"."))
GetExtendName = ExtName
end function
%>
<!--#include file="inc/cls_load.inc"-->
<!--#include file="inc/js_.inc"-->
<%
dim upload,upfile,sql
dim fromnn,fromdd,fromaa,fromtt,fromff,fromyy
set upload=new upload_5xSoft ''建立上传对象
'userid = session("userid")
'下面是获取前一页面中的input元素的方法,用upload.form来获取,相当于asp中的request.form
fromnn = upload.form("nn")
fromdd = upload.form("dd")
fromaa = upload.form("aa")
fromtt = upload.form("tt")
fromff = upload.form("ff")
fromyy = upload.form("yy")
set upload=new upload_5xsoft
'下面是用file对象来存储上一页面中的file控件的图片值,其中包括图片的路径,大小等等
set upfile=upload.file("logo")
if upfile.FileSize>0 then
if GetExtendName(upfile.FileName)<>"swf" and GetExtendName(upfile.FileName)<>"jpg" and GetExtendName(upfile.FileName)<>"gif" then
response.redirect("result.asp?msg=不是正确的图片格式。")
end if
end if
'sql="SELECT TOP 1 id,name,logo,description,address,tel,fax,yydata FROM jianjie order by id desc"
set rs=server.createobject("adodb.recordset")
rs.Open sql,objconn,1,2
while not rs.EOF
if trim(fromnn) = trim(rs("name")) then
rs.Close
'CloseConnection(objconn)
Alert_Back("此商家已经存在,请重新输入!")
Response.End
end if
rs.MoveNext
wend
'rs.addnew
rs("name")=fromnn
rs("description")=fromdd
rs("address")=fromaa
rs("tel")=fromtt
rs("fax")=fromff
rs("yydata")=fromyy
rs.update
rs.close()
rs.open sql,objconn,1,2
'response.write rs("id")
'response.End()
if upfile.FileSize>0 then
upfile.SaveAs Server.mappath("images/image"&rs("id")&"."&GetExtendName(upfile.FileName))
rs("logo") = "images/"&"image"&rs("id")&"."&GetExtendName(upfile.FileName)
rs.update
end if
'rs.close
'objconn.execute "insert into company (name,description) values('"&fromnn&"','"&fromdd&"')"
'objconn.close
'rs.close
response.Redirect("x1.asp")
function GetExtendName(FileName)//获取扩展名
dim ExtName
ExtName = LCase(FileName)
ExtName = right(ExtName,3)
ExtName = right(ExtName,3-Instr(ExtName,"."))
GetExtendName = ExtName
end function
%>
#8
<%
'''''''''''''''''''''''''''''''''''''''''''''''''
'
'请保留此信息: 稻香老农制作,
'
'''''''''''''''''''''''''''''''''''''''''''''''''
dim upfile_5xSoft_Stream
Class upload_5xSoft
dim Form,File,Version
Private Sub Class_Initialize
dim iStart,iFileNameStart,iFileNameEnd,iEnd,vbEnter,iFormStart,iFormEnd,theFile
dim strDiv,mFormName,mFormValue,mFileName,mFileSize,mFilePath,iDivLen,mStr
Version=""
if Request.TotalBytes<1 or request.TotalBytes>204800 then
Response.Write "<script language=javascript>alert('请将图片大小限制在200K以下!');"
Response.Write "javascript:history.back();</script>"
Response.End
'/////////////////////
end if
'Exit Sub
'/////////////////////
set Form=CreateObject("Scripting.Dictionary")
set File=CreateObject("Scripting.Dictionary")
set upfile_5xSoft_Stream=CreateObject("Adodb.Stream")
upfile_5xSoft_Stream.mode=3
upfile_5xSoft_Stream.type=1
upfile_5xSoft_Stream.open
upfile_5xSoft_Stream.write Request.BinaryRead(Request.TotalBytes)
vbEnter=Chr(13)&Chr(10)
iDivLen=inString(1,vbEnter)+1
strDiv=subString(1,iDivLen)
iFormStart=iDivLen
iFormEnd=inString(iformStart,strDiv)-1
while iFormStart < iFormEnd
iStart=inString(iFormStart,"name=""")
iEnd=inString(iStart+6,"""")
mFormName=subString(iStart+6,iEnd-iStart-6)
iFileNameStart=inString(iEnd+1,"filename=""")
if iFileNameStart>0 and iFileNameStart<iFormEnd then
iFileNameEnd=inString(iFileNameStart+10,"""")
mFileName=subString(iFileNameStart+10,iFileNameEnd-iFileNameStart-10)
iStart=inString(iFileNameEnd+1,vbEnter&vbEnter)
iEnd=inString(iStart+4,vbEnter&strDiv)
if iEnd>iStart then
mFileSize=iEnd-iStart-4
else
mFileSize=0
end if
set theFile=new FileInfo
theFile.FileName=getFileName(mFileName)
theFile.FilePath=getFilePath(mFileName)
theFile.FileSize=mFileSize
theFile.FileStart=iStart+4
theFile.FormName=FormName
file.add mFormName,theFile
else
iStart=inString(iEnd+1,vbEnter&vbEnter)
iEnd=inString(iStart+4,vbEnter&strDiv)
if iEnd>iStart then
mFormValue=subString(iStart+4,iEnd-iStart-4)
else
mFormValue=""
end if
form.Add mFormName,mFormValue
end if
iFormStart=iformEnd+iDivLen
iFormEnd=inString(iformStart,strDiv)-1
wend
End Sub
Private Function subString(theStart,theLen)
dim i,c,stemp
upfile_5xSoft_Stream.Position=theStart-1
stemp=""
for i=1 to theLen
if upfile_5xSoft_Stream.EOS then Exit for
c=ascB(upfile_5xSoft_Stream.Read(1))
If c > 127 Then
if upfile_5xSoft_Stream.EOS then Exit for
stemp=stemp&Chr(AscW(ChrB(AscB(upfile_5xSoft_Stream.Read(1)))&ChrB(c)))
i=i+1
else
stemp=stemp&Chr(c)
End If
Next
subString=stemp
End function
Private Function inString(theStart,varStr)
dim i,j,bt,theLen,str
InString=0
Str=toByte(varStr)
theLen=LenB(Str)
for i=theStart to upfile_5xSoft_Stream.Size-theLen
if i>upfile_5xSoft_Stream.size then exit Function
upfile_5xSoft_Stream.Position=i-1
if AscB(upfile_5xSoft_Stream.Read(1))=AscB(midB(Str,1)) then
InString=i
for j=2 to theLen
if upfile_5xSoft_Stream.EOS then
inString=0
Exit for
end if
if AscB(upfile_5xSoft_Stream.write(1))<>AscB(MidB(Str,j,1)) then
InString=0
Exit For
end if
next
if InString<>0 then Exit Function
end if
next
End Function
Private Sub Class_Terminate
form.RemoveAll
file.RemoveAll
set form=nothing
set file=nothing
upfile_5xSoft_Stream.close
set upfile_5xSoft_Stream=nothing
End Sub
Private function GetFilePath(FullPath)
If FullPath <> "" Then
GetFilePath = left(FullPath,InStrRev(FullPath, "\"))
Else
GetFilePath = ""
End If
End function
Private function GetFileName(FullPath)
If FullPath <> "" Then
GetFileName = mid(FullPath,InStrRev(FullPath, "\")+1)
Else
GetFileName = ""
End If
End function
Private function toByte(Str)
dim i,iCode,c,iLow,iHigh
toByte=""
For i=1 To Len(Str)
c=mid(Str,i,1)
iCode =Asc(c)
If iCode<0 Then iCode = iCode + 65535
If iCode>255 Then
iLow = Left(Hex(Asc(c)),2)
iHigh =Right(Hex(Asc(c)),2)
toByte = toByte & chrB("&H"&iLow) & chrB("&H"&iHigh)
Else
toByte = toByte & chrB(AscB(c))
End If
Next
End function
End Class
Class FileInfo
dim FormName,FileName,FilePath,FileSize,FileStart
Private Sub Class_Initialize
FileName = ""
FilePath = ""
FileSize = 0
FileStart= 0
FormName = ""
End Sub
Public function SaveAs(FullPath)
dim dr,ErrorChar,i
SaveAs=1
if trim(fullpath)="" or FileSize=0 or FileStart=0 or FileName="" then exit function
if FileStart=0 or right(fullpath,1)="/" then exit function
set dr=CreateObject("Adodb.Stream")
dr.Mode=3
dr.Type=1
dr.Open
upfile_5xSoft_Stream.position=FileStart-1
upfile_5xSoft_Stream.copyto dr,FileSize
dr.SaveToFile FullPath,2
dr.Close
set dr=nothing
SaveAs=0
end function
End Class
%>
'''''''''''''''''''''''''''''''''''''''''''''''''
'
'请保留此信息: 稻香老农制作,
'
'''''''''''''''''''''''''''''''''''''''''''''''''
dim upfile_5xSoft_Stream
Class upload_5xSoft
dim Form,File,Version
Private Sub Class_Initialize
dim iStart,iFileNameStart,iFileNameEnd,iEnd,vbEnter,iFormStart,iFormEnd,theFile
dim strDiv,mFormName,mFormValue,mFileName,mFileSize,mFilePath,iDivLen,mStr
Version=""
if Request.TotalBytes<1 or request.TotalBytes>204800 then
Response.Write "<script language=javascript>alert('请将图片大小限制在200K以下!');"
Response.Write "javascript:history.back();</script>"
Response.End
'/////////////////////
end if
'Exit Sub
'/////////////////////
set Form=CreateObject("Scripting.Dictionary")
set File=CreateObject("Scripting.Dictionary")
set upfile_5xSoft_Stream=CreateObject("Adodb.Stream")
upfile_5xSoft_Stream.mode=3
upfile_5xSoft_Stream.type=1
upfile_5xSoft_Stream.open
upfile_5xSoft_Stream.write Request.BinaryRead(Request.TotalBytes)
vbEnter=Chr(13)&Chr(10)
iDivLen=inString(1,vbEnter)+1
strDiv=subString(1,iDivLen)
iFormStart=iDivLen
iFormEnd=inString(iformStart,strDiv)-1
while iFormStart < iFormEnd
iStart=inString(iFormStart,"name=""")
iEnd=inString(iStart+6,"""")
mFormName=subString(iStart+6,iEnd-iStart-6)
iFileNameStart=inString(iEnd+1,"filename=""")
if iFileNameStart>0 and iFileNameStart<iFormEnd then
iFileNameEnd=inString(iFileNameStart+10,"""")
mFileName=subString(iFileNameStart+10,iFileNameEnd-iFileNameStart-10)
iStart=inString(iFileNameEnd+1,vbEnter&vbEnter)
iEnd=inString(iStart+4,vbEnter&strDiv)
if iEnd>iStart then
mFileSize=iEnd-iStart-4
else
mFileSize=0
end if
set theFile=new FileInfo
theFile.FileName=getFileName(mFileName)
theFile.FilePath=getFilePath(mFileName)
theFile.FileSize=mFileSize
theFile.FileStart=iStart+4
theFile.FormName=FormName
file.add mFormName,theFile
else
iStart=inString(iEnd+1,vbEnter&vbEnter)
iEnd=inString(iStart+4,vbEnter&strDiv)
if iEnd>iStart then
mFormValue=subString(iStart+4,iEnd-iStart-4)
else
mFormValue=""
end if
form.Add mFormName,mFormValue
end if
iFormStart=iformEnd+iDivLen
iFormEnd=inString(iformStart,strDiv)-1
wend
End Sub
Private Function subString(theStart,theLen)
dim i,c,stemp
upfile_5xSoft_Stream.Position=theStart-1
stemp=""
for i=1 to theLen
if upfile_5xSoft_Stream.EOS then Exit for
c=ascB(upfile_5xSoft_Stream.Read(1))
If c > 127 Then
if upfile_5xSoft_Stream.EOS then Exit for
stemp=stemp&Chr(AscW(ChrB(AscB(upfile_5xSoft_Stream.Read(1)))&ChrB(c)))
i=i+1
else
stemp=stemp&Chr(c)
End If
Next
subString=stemp
End function
Private Function inString(theStart,varStr)
dim i,j,bt,theLen,str
InString=0
Str=toByte(varStr)
theLen=LenB(Str)
for i=theStart to upfile_5xSoft_Stream.Size-theLen
if i>upfile_5xSoft_Stream.size then exit Function
upfile_5xSoft_Stream.Position=i-1
if AscB(upfile_5xSoft_Stream.Read(1))=AscB(midB(Str,1)) then
InString=i
for j=2 to theLen
if upfile_5xSoft_Stream.EOS then
inString=0
Exit for
end if
if AscB(upfile_5xSoft_Stream.write(1))<>AscB(MidB(Str,j,1)) then
InString=0
Exit For
end if
next
if InString<>0 then Exit Function
end if
next
End Function
Private Sub Class_Terminate
form.RemoveAll
file.RemoveAll
set form=nothing
set file=nothing
upfile_5xSoft_Stream.close
set upfile_5xSoft_Stream=nothing
End Sub
Private function GetFilePath(FullPath)
If FullPath <> "" Then
GetFilePath = left(FullPath,InStrRev(FullPath, "\"))
Else
GetFilePath = ""
End If
End function
Private function GetFileName(FullPath)
If FullPath <> "" Then
GetFileName = mid(FullPath,InStrRev(FullPath, "\")+1)
Else
GetFileName = ""
End If
End function
Private function toByte(Str)
dim i,iCode,c,iLow,iHigh
toByte=""
For i=1 To Len(Str)
c=mid(Str,i,1)
iCode =Asc(c)
If iCode<0 Then iCode = iCode + 65535
If iCode>255 Then
iLow = Left(Hex(Asc(c)),2)
iHigh =Right(Hex(Asc(c)),2)
toByte = toByte & chrB("&H"&iLow) & chrB("&H"&iHigh)
Else
toByte = toByte & chrB(AscB(c))
End If
Next
End function
End Class
Class FileInfo
dim FormName,FileName,FilePath,FileSize,FileStart
Private Sub Class_Initialize
FileName = ""
FilePath = ""
FileSize = 0
FileStart= 0
FormName = ""
End Sub
Public function SaveAs(FullPath)
dim dr,ErrorChar,i
SaveAs=1
if trim(fullpath)="" or FileSize=0 or FileStart=0 or FileName="" then exit function
if FileStart=0 or right(fullpath,1)="/" then exit function
set dr=CreateObject("Adodb.Stream")
dr.Mode=3
dr.Type=1
dr.Open
upfile_5xSoft_Stream.position=FileStart-1
upfile_5xSoft_Stream.copyto dr,FileSize
dr.SaveToFile FullPath,2
dr.Close
set dr=nothing
SaveAs=0
end function
End Class
%>
#9
总是提示我这个文件有错误inc/cls_load.inc<%
'''''''''''''''''''''''''''''''''''''''''''''''''
'
'请保留此信息: 稻香老农制作,
'
'''''''''''''''''''''''''''''''''''''''''''''''''
dim upfile_5xSoft_Stream
Class upload_5xSoft
dim Form,File,Version
Private Sub Class_Initialize
dim iStart,iFileNameStart,iFileNameEnd,iEnd,vbEnter,iFormStart,iFormEnd,theFile
dim strDiv,mFormName,mFormValue,mFileName,mFileSize,mFilePath,iDivLen,mStr
Version=""
if Request.TotalBytes<1 or request.TotalBytes>204800 then
Response.Write "<script language=javascript>alert('请将图片大小限制在200K以下!');"
Response.Write "javascript:history.back();</script>"
Response.End
'/////////////////////
end if
'Exit Sub
'/////////////////////
set Form=CreateObject("Scripting.Dictionary")
set File=CreateObject("Scripting.Dictionary")
set upfile_5xSoft_Stream=CreateObject("Adodb.Stream")
upfile_5xSoft_Stream.mode=3
upfile_5xSoft_Stream.type=1
upfile_5xSoft_Stream.open
upfile_5xSoft_Stream.write Request.BinaryRead(Request.TotalBytes)
vbEnter=Chr(13)&Chr(10)
iDivLen=inString(1,vbEnter)+1
strDiv=subString(1,iDivLen)
iFormStart=iDivLen
iFormEnd=inString(iformStart,strDiv)-1
while iFormStart < iFormEnd
iStart=inString(iFormStart,"name=""")
iEnd=inString(iStart+6,"""")
mFormName=subString(iStart+6,iEnd-iStart-6)
iFileNameStart=inString(iEnd+1,"filename=""")
if iFileNameStart>0 and iFileNameStart<iFormEnd then
iFileNameEnd=inString(iFileNameStart+10,"""")
mFileName=subString(iFileNameStart+10,iFileNameEnd-iFileNameStart-10)
iStart=inString(iFileNameEnd+1,vbEnter&vbEnter)
iEnd=inString(iStart+4,vbEnter&strDiv)
if iEnd>iStart then
mFileSize=iEnd-iStart-4
else
mFileSize=0
end if
set theFile=new FileInfo
theFile.FileName=getFileName(mFileName)
theFile.FilePath=getFilePath(mFileName)
theFile.FileSize=mFileSize
theFile.FileStart=iStart+4
theFile.FormName=FormName
file.add mFormName,theFile
else
iStart=inString(iEnd+1,vbEnter&vbEnter)
iEnd=inString(iStart+4,vbEnter&strDiv)
if iEnd>iStart then
mFormValue=subString(iStart+4,iEnd-iStart-4)
else
mFormValue=""
end if
form.Add mFormName,mFormValue
end if
iFormStart=iformEnd+iDivLen
iFormEnd=inString(iformStart,strDiv)-1
wend
End Sub
Private Function subString(theStart,theLen)
dim i,c,stemp
upfile_5xSoft_Stream.Position=theStart-1
stemp=""
for i=1 to theLen
if upfile_5xSoft_Stream.EOS then Exit for
c=ascB(upfile_5xSoft_Stream.Read(1))
If c > 127 Then
if upfile_5xSoft_Stream.EOS then Exit for
stemp=stemp&Chr(AscW(ChrB(AscB(upfile_5xSoft_Stream.Read(1)))&ChrB(c)))
i=i+1
else
stemp=stemp&Chr(c)
End If
Next
subString=stemp
End function
Private Function inString(theStart,varStr)
dim i,j,bt,theLen,str
InString=0
Str=toByte(varStr)
theLen=LenB(Str)
for i=theStart to upfile_5xSoft_Stream.Size-theLen
if i>upfile_5xSoft_Stream.size then exit Function
upfile_5xSoft_Stream.Position=i-1
if AscB(upfile_5xSoft_Stream.Read(1))=AscB(midB(Str,1)) then
InString=i
for j=2 to theLen
if upfile_5xSoft_Stream.EOS then
inString=0
Exit for
end if
if AscB(upfile_5xSoft_Stream.write(1))<>AscB(MidB(Str,j,1)) then
InString=0
Exit For
end if
next
if InString<>0 then Exit Function
end if
next
End Function
Private Sub Class_Terminate
form.RemoveAll
file.RemoveAll
set form=nothing
set file=nothing
upfile_5xSoft_Stream.close
set upfile_5xSoft_Stream=nothing
End Sub
Private function GetFilePath(FullPath)
If FullPath <> "" Then
GetFilePath = left(FullPath,InStrRev(FullPath, "\"))
Else
GetFilePath = ""
End If
End function
Private function GetFileName(FullPath)
If FullPath <> "" Then
GetFileName = mid(FullPath,InStrRev(FullPath, "\")+1)
Else
GetFileName = ""
End If
End function
Private function toByte(Str)
dim i,iCode,c,iLow,iHigh
toByte=""
For i=1 To Len(Str)
c=mid(Str,i,1)
iCode =Asc(c)
If iCode<0 Then iCode = iCode + 65535
If iCode>255 Then
iLow = Left(Hex(Asc(c)),2)
iHigh =Right(Hex(Asc(c)),2)
toByte = toByte & chrB("&H"&iLow) & chrB("&H"&iHigh)
Else
toByte = toByte & chrB(AscB(c))
End If
Next
End function
End Class
Class FileInfo
dim FormName,FileName,FilePath,FileSize,FileStart
Private Sub Class_Initialize
FileName = ""
FilePath = ""
FileSize = 0
FileStart= 0
FormName = ""
End Sub
Public function SaveAs(FullPath)
dim dr,ErrorChar,i
SaveAs=1
if trim(fullpath)="" or FileSize=0 or FileStart=0 or FileName="" then exit function
if FileStart=0 or right(fullpath,1)="/" then exit function
set dr=CreateObject("Adodb.Stream")
dr.Mode=3
dr.Type=1
dr.Open
upfile_5xSoft_Stream.position=FileStart-1
upfile_5xSoft_Stream.copyto dr,FileSize
dr.SaveToFile FullPath,2
dr.Close
set dr=nothing
SaveAs=0
end function
End Class
%>
'''''''''''''''''''''''''''''''''''''''''''''''''
'
'请保留此信息: 稻香老农制作,
'
'''''''''''''''''''''''''''''''''''''''''''''''''
dim upfile_5xSoft_Stream
Class upload_5xSoft
dim Form,File,Version
Private Sub Class_Initialize
dim iStart,iFileNameStart,iFileNameEnd,iEnd,vbEnter,iFormStart,iFormEnd,theFile
dim strDiv,mFormName,mFormValue,mFileName,mFileSize,mFilePath,iDivLen,mStr
Version=""
if Request.TotalBytes<1 or request.TotalBytes>204800 then
Response.Write "<script language=javascript>alert('请将图片大小限制在200K以下!');"
Response.Write "javascript:history.back();</script>"
Response.End
'/////////////////////
end if
'Exit Sub
'/////////////////////
set Form=CreateObject("Scripting.Dictionary")
set File=CreateObject("Scripting.Dictionary")
set upfile_5xSoft_Stream=CreateObject("Adodb.Stream")
upfile_5xSoft_Stream.mode=3
upfile_5xSoft_Stream.type=1
upfile_5xSoft_Stream.open
upfile_5xSoft_Stream.write Request.BinaryRead(Request.TotalBytes)
vbEnter=Chr(13)&Chr(10)
iDivLen=inString(1,vbEnter)+1
strDiv=subString(1,iDivLen)
iFormStart=iDivLen
iFormEnd=inString(iformStart,strDiv)-1
while iFormStart < iFormEnd
iStart=inString(iFormStart,"name=""")
iEnd=inString(iStart+6,"""")
mFormName=subString(iStart+6,iEnd-iStart-6)
iFileNameStart=inString(iEnd+1,"filename=""")
if iFileNameStart>0 and iFileNameStart<iFormEnd then
iFileNameEnd=inString(iFileNameStart+10,"""")
mFileName=subString(iFileNameStart+10,iFileNameEnd-iFileNameStart-10)
iStart=inString(iFileNameEnd+1,vbEnter&vbEnter)
iEnd=inString(iStart+4,vbEnter&strDiv)
if iEnd>iStart then
mFileSize=iEnd-iStart-4
else
mFileSize=0
end if
set theFile=new FileInfo
theFile.FileName=getFileName(mFileName)
theFile.FilePath=getFilePath(mFileName)
theFile.FileSize=mFileSize
theFile.FileStart=iStart+4
theFile.FormName=FormName
file.add mFormName,theFile
else
iStart=inString(iEnd+1,vbEnter&vbEnter)
iEnd=inString(iStart+4,vbEnter&strDiv)
if iEnd>iStart then
mFormValue=subString(iStart+4,iEnd-iStart-4)
else
mFormValue=""
end if
form.Add mFormName,mFormValue
end if
iFormStart=iformEnd+iDivLen
iFormEnd=inString(iformStart,strDiv)-1
wend
End Sub
Private Function subString(theStart,theLen)
dim i,c,stemp
upfile_5xSoft_Stream.Position=theStart-1
stemp=""
for i=1 to theLen
if upfile_5xSoft_Stream.EOS then Exit for
c=ascB(upfile_5xSoft_Stream.Read(1))
If c > 127 Then
if upfile_5xSoft_Stream.EOS then Exit for
stemp=stemp&Chr(AscW(ChrB(AscB(upfile_5xSoft_Stream.Read(1)))&ChrB(c)))
i=i+1
else
stemp=stemp&Chr(c)
End If
Next
subString=stemp
End function
Private Function inString(theStart,varStr)
dim i,j,bt,theLen,str
InString=0
Str=toByte(varStr)
theLen=LenB(Str)
for i=theStart to upfile_5xSoft_Stream.Size-theLen
if i>upfile_5xSoft_Stream.size then exit Function
upfile_5xSoft_Stream.Position=i-1
if AscB(upfile_5xSoft_Stream.Read(1))=AscB(midB(Str,1)) then
InString=i
for j=2 to theLen
if upfile_5xSoft_Stream.EOS then
inString=0
Exit for
end if
if AscB(upfile_5xSoft_Stream.write(1))<>AscB(MidB(Str,j,1)) then
InString=0
Exit For
end if
next
if InString<>0 then Exit Function
end if
next
End Function
Private Sub Class_Terminate
form.RemoveAll
file.RemoveAll
set form=nothing
set file=nothing
upfile_5xSoft_Stream.close
set upfile_5xSoft_Stream=nothing
End Sub
Private function GetFilePath(FullPath)
If FullPath <> "" Then
GetFilePath = left(FullPath,InStrRev(FullPath, "\"))
Else
GetFilePath = ""
End If
End function
Private function GetFileName(FullPath)
If FullPath <> "" Then
GetFileName = mid(FullPath,InStrRev(FullPath, "\")+1)
Else
GetFileName = ""
End If
End function
Private function toByte(Str)
dim i,iCode,c,iLow,iHigh
toByte=""
For i=1 To Len(Str)
c=mid(Str,i,1)
iCode =Asc(c)
If iCode<0 Then iCode = iCode + 65535
If iCode>255 Then
iLow = Left(Hex(Asc(c)),2)
iHigh =Right(Hex(Asc(c)),2)
toByte = toByte & chrB("&H"&iLow) & chrB("&H"&iHigh)
Else
toByte = toByte & chrB(AscB(c))
End If
Next
End function
End Class
Class FileInfo
dim FormName,FileName,FilePath,FileSize,FileStart
Private Sub Class_Initialize
FileName = ""
FilePath = ""
FileSize = 0
FileStart= 0
FormName = ""
End Sub
Public function SaveAs(FullPath)
dim dr,ErrorChar,i
SaveAs=1
if trim(fullpath)="" or FileSize=0 or FileStart=0 or FileName="" then exit function
if FileStart=0 or right(fullpath,1)="/" then exit function
set dr=CreateObject("Adodb.Stream")
dr.Mode=3
dr.Type=1
dr.Open
upfile_5xSoft_Stream.position=FileStart-1
upfile_5xSoft_Stream.copyto dr,FileSize
dr.SaveToFile FullPath,2
dr.Close
set dr=nothing
SaveAs=0
end function
End Class
%>
#10
分两步:1、修改图片其他信息,通过表单。
2、图片上传,同时自动修改数据库图片名。
2、图片上传,同时自动修改数据库图片名。
#11
错误提示:Microsoft VBScript 编译器错误 错误 '800a03f6'
缺少 'End'
/iisHelp/common/500-100.asp,行242
ADODB.Stream 错误 '800a0bb9'
变量或者类型不正确,或者不在可以接受的范围之内,要不就是与其他数据冲突。
/elegance/back/inc/cls_load.inc,行33
缺少 'End'
/iisHelp/common/500-100.asp,行242
ADODB.Stream 错误 '800a0bb9'
变量或者类型不正确,或者不在可以接受的范围之内,要不就是与其他数据冲突。
/elegance/back/inc/cls_load.inc,行33
#12
各位帮帮忙呀!!!
#13
通过一下的两个函数可以实现图片,文字的同时提交处理。
Function BinaryToString(str)
strto = ""
for i=1 to lenb(str)
if AscB(MidB(str, i, 1)) > 127 then
strto = strto & chr(Ascb(MidB(str, i, 1))*256+Ascb(MidB(str, i+1, 1)))
i = i + 1
else
strto = strto & Chr(AscB(MidB(str, i, 1)))
end if
next
BinaryToString=strto
End Function
function gainformdata(n)
dim formsize,formdata,divider,datastart,dataend
redim mydata(n-1)
formsize = Request.TotalBytes
formdata = Request.BinaryRead(formsize)
for i=1 to n
bncrlf = chrB(13) & chrB(10)
divider = leftB(formdata,clng(instrB(formdata,bncrlf))-1)
datastart = instrB(formdata,bncrlf & bncrlf)+4
dataend = instrB(datastart+1,formdata,divider) - datastart-2
mydata(i-1) = midB(formdata,datastart,dataend)
formdata=rightB(formdata,clng(formsize-instrB(datastart+1,formdata,divider))+1)
formsize=lenB(formdata)
next
gainformdata=mydata
end function
Demo:
a.htm:
<form name="form1" method="post" action="b.asp" enctype="multipart/form-data">
<textarea name="txt"></textarea>
<input type="file" name="file">
<input type="submit" name="Submit" value="提交">
</form>
b.asp:
'链接数据库
data=gainfromdata(2)
rs("txt")=binarytostring(data(0))
rs("img").appendchunk=data(1)
用ASP实现无组件上传/下载文件
'
' 功能简介
' 将上传的文件数据保存到数据库中,可以处理表单中的多个上传文件的情况
' 适用于各种数据库,使用ADO的方法连接数据库
' 本示例中使用的是ACCESS数据库:zj.mdb
' 表:tb_img(id int(自增列),path text(255) 保存上传文件的目录
' ,fname text(250) 保存上传的文件名,type test(250) 保存上传文件的类型
' ,img ole对象 保存上传的文件内容
'
' 邹建 2003.10
'==================================================================
'==================================================================
'
' 上传文件的HTML页: zj_up.htm
'
'==================================================================
<html>
<head>
<title>文件上传保存到数据库中</title>
</head>
<body>
<form name="form1" enctype="multipart/form-data" method="post" action="zj_up.asp">
<p>
<input type="file" name="file">
<input type="submit" name="Submit" value="上传">
</p>
</form>
</body>
</html>
Function BinaryToString(str)
strto = ""
for i=1 to lenb(str)
if AscB(MidB(str, i, 1)) > 127 then
strto = strto & chr(Ascb(MidB(str, i, 1))*256+Ascb(MidB(str, i+1, 1)))
i = i + 1
else
strto = strto & Chr(AscB(MidB(str, i, 1)))
end if
next
BinaryToString=strto
End Function
function gainformdata(n)
dim formsize,formdata,divider,datastart,dataend
redim mydata(n-1)
formsize = Request.TotalBytes
formdata = Request.BinaryRead(formsize)
for i=1 to n
bncrlf = chrB(13) & chrB(10)
divider = leftB(formdata,clng(instrB(formdata,bncrlf))-1)
datastart = instrB(formdata,bncrlf & bncrlf)+4
dataend = instrB(datastart+1,formdata,divider) - datastart-2
mydata(i-1) = midB(formdata,datastart,dataend)
formdata=rightB(formdata,clng(formsize-instrB(datastart+1,formdata,divider))+1)
formsize=lenB(formdata)
next
gainformdata=mydata
end function
Demo:
a.htm:
<form name="form1" method="post" action="b.asp" enctype="multipart/form-data">
<textarea name="txt"></textarea>
<input type="file" name="file">
<input type="submit" name="Submit" value="提交">
</form>
b.asp:
'链接数据库
data=gainfromdata(2)
rs("txt")=binarytostring(data(0))
rs("img").appendchunk=data(1)
用ASP实现无组件上传/下载文件
'
' 功能简介
' 将上传的文件数据保存到数据库中,可以处理表单中的多个上传文件的情况
' 适用于各种数据库,使用ADO的方法连接数据库
' 本示例中使用的是ACCESS数据库:zj.mdb
' 表:tb_img(id int(自增列),path text(255) 保存上传文件的目录
' ,fname text(250) 保存上传的文件名,type test(250) 保存上传文件的类型
' ,img ole对象 保存上传的文件内容
'
' 邹建 2003.10
'==================================================================
'==================================================================
'
' 上传文件的HTML页: zj_up.htm
'
'==================================================================
<html>
<head>
<title>文件上传保存到数据库中</title>
</head>
<body>
<form name="form1" enctype="multipart/form-data" method="post" action="zj_up.asp">
<p>
<input type="file" name="file">
<input type="submit" name="Submit" value="上传">
</p>
</form>
</body>
</html>
#1
关注中,我也有此同类问题
#2
什么错?
#3
<!--#include file="inc/ConnectDatabase.inc"-->
<!--#include file="inc/js_.inc"-->
<!--#include virtual="inc/TurnPage.inc"-->
<%
dim sql
sql = "select * from jianjie order by id desc"
set rs = server.CreateObject("adodb.recordset")
rs.Open sql,objconn,1,1
%>
<head>
<title>商家修改</title>
<link rel="stylesheet" href="css/css.css" type="text/css">
<script language=javascript>
function mOvr(src,clrOver)
{ if (!src.contains(event.fromElement))
{ src.style.cursor = 'hand'; src.bgColor = clrOver; }
}
function mOut(src,clrIn)
{ if (!src.contains(event.toElement))
{ src.style.cursor = 'default'; src.bgColor = clrIn; }
}
function mClk(src)
{ if(event.srcElement.tagName=='TD')
{src.children.tags('A')[0].click();}
}
function modi(id,name){
window.open("xx2.asp?id="+id+"&name="+name,"xxrl","top=160,left=200,width=370,height=250");
}
function show(id){
window.open("colist.asp?id="+id,"xxrl","top=50,left=40,width=664,height=440");
}
</script>
</head>
<body topmargin="0" leftmargin="0">
<div align="center">
<center>
<table border="0" width="650" cellspacing="0" cellpadding="0" ID="Table1">
<tr>
<td bgcolor="#D6DEF3" width="655"> <p align="left">富贵园后台程序商家修改</p></td>
<td bgcolor="#F8E0D8" width="655" > </td>
</tr>
<tr>
<td align="center" width="655" bgcolor="#FFFFFF" height="10" valign="middle" colspan="2">
<%
dim RowCount
RowCount = 10
call TurnPage(rs,RowCount)
%>
</td>
</tr>
<tr>
<td align="center" width="655" bgcolor="#FFFFFF" valign="top" colspan="2">
<div align="left">
<table width="650" border="0" cellspacing="1" cellpadding="1" class="hello1" id="Table2">
<tr>
<td width="68" align="center" bgcolor="#D4D4D4">商家名称</td>
<td width="166" align="center" bgcolor="#D4D4D4">商家地址</td>
<td width="96" align="center" bgcolor="#D4D4D4">商家电话</td>
<td width="92" align="center" bgcolor="#D4D4D4">商家传真</td>
<td width="69" align="center" bgcolor="#D4D4D4">营业时间</td>
<td align="center" width="69" bgcolor="#D4D4D4">详细资料</td>
<td align="center" width="66" bgcolor="#D4D4D4">修改</td>
</tr>
<%while not rs.EOF and RowCount>0%>
<tr bgcolor="#FDF2FB" onMouseOver="mOvr(this,'#B4DEDE');" onMouseOut="mOut(this,'#FDF2FB');" class="hello1">
<td width="68" align="center"><%=trim(rs("name"))%></td>
<td width="166" align="center"><%=trim(rs("address"))%></td>
<td width="96" align="center"><%=trim(rs("tel"))%></td>
<td align="center" width="92"><%=trim(rs("fax"))%> </td>
<td align="center" width="69"><%=trim(rs("yydata"))%></td>
<td align="center" width="69"><a href="javascript:show(<%=trim(rs("id"))%>);"><img border="0" src="images/xx.gif" width="20" height="18"></a></td>
<td align="center" width="66"><a href="javascript:modi(<%=trim(rs("id"))%>,'<%=trim(rs("name"))%>');"><img src="images/modi.gif" width="25" height="21" border="0"></a></td>
</tr>
<%
RowCount = RowCount-1
rs.MoveNext
wend
rs.Close
objconn.close
%>
</table>
</div></td>
</tr>
</table>
</center>
</div>
<p align="center">
<p>
<!--#include file="inc/js_.inc"-->
<!--#include virtual="inc/TurnPage.inc"-->
<%
dim sql
sql = "select * from jianjie order by id desc"
set rs = server.CreateObject("adodb.recordset")
rs.Open sql,objconn,1,1
%>
<head>
<title>商家修改</title>
<link rel="stylesheet" href="css/css.css" type="text/css">
<script language=javascript>
function mOvr(src,clrOver)
{ if (!src.contains(event.fromElement))
{ src.style.cursor = 'hand'; src.bgColor = clrOver; }
}
function mOut(src,clrIn)
{ if (!src.contains(event.toElement))
{ src.style.cursor = 'default'; src.bgColor = clrIn; }
}
function mClk(src)
{ if(event.srcElement.tagName=='TD')
{src.children.tags('A')[0].click();}
}
function modi(id,name){
window.open("xx2.asp?id="+id+"&name="+name,"xxrl","top=160,left=200,width=370,height=250");
}
function show(id){
window.open("colist.asp?id="+id,"xxrl","top=50,left=40,width=664,height=440");
}
</script>
</head>
<body topmargin="0" leftmargin="0">
<div align="center">
<center>
<table border="0" width="650" cellspacing="0" cellpadding="0" ID="Table1">
<tr>
<td bgcolor="#D6DEF3" width="655"> <p align="left">富贵园后台程序商家修改</p></td>
<td bgcolor="#F8E0D8" width="655" > </td>
</tr>
<tr>
<td align="center" width="655" bgcolor="#FFFFFF" height="10" valign="middle" colspan="2">
<%
dim RowCount
RowCount = 10
call TurnPage(rs,RowCount)
%>
</td>
</tr>
<tr>
<td align="center" width="655" bgcolor="#FFFFFF" valign="top" colspan="2">
<div align="left">
<table width="650" border="0" cellspacing="1" cellpadding="1" class="hello1" id="Table2">
<tr>
<td width="68" align="center" bgcolor="#D4D4D4">商家名称</td>
<td width="166" align="center" bgcolor="#D4D4D4">商家地址</td>
<td width="96" align="center" bgcolor="#D4D4D4">商家电话</td>
<td width="92" align="center" bgcolor="#D4D4D4">商家传真</td>
<td width="69" align="center" bgcolor="#D4D4D4">营业时间</td>
<td align="center" width="69" bgcolor="#D4D4D4">详细资料</td>
<td align="center" width="66" bgcolor="#D4D4D4">修改</td>
</tr>
<%while not rs.EOF and RowCount>0%>
<tr bgcolor="#FDF2FB" onMouseOver="mOvr(this,'#B4DEDE');" onMouseOut="mOut(this,'#FDF2FB');" class="hello1">
<td width="68" align="center"><%=trim(rs("name"))%></td>
<td width="166" align="center"><%=trim(rs("address"))%></td>
<td width="96" align="center"><%=trim(rs("tel"))%></td>
<td align="center" width="92"><%=trim(rs("fax"))%> </td>
<td align="center" width="69"><%=trim(rs("yydata"))%></td>
<td align="center" width="69"><a href="javascript:show(<%=trim(rs("id"))%>);"><img border="0" src="images/xx.gif" width="20" height="18"></a></td>
<td align="center" width="66"><a href="javascript:modi(<%=trim(rs("id"))%>,'<%=trim(rs("name"))%>');"><img src="images/modi.gif" width="25" height="21" border="0"></a></td>
</tr>
<%
RowCount = RowCount-1
rs.MoveNext
wend
rs.Close
objconn.close
%>
</table>
</div></td>
</tr>
</table>
</center>
</div>
<p align="center">
<p>
#4
显示选中的记录页<!--#include file="inc/ConnectDatabase.inc"-->
<%
dim id1,name1
id1=trim(request("id"))
name1=trim(request("name"))
dim sql_
sql_="select * from jianjie where id='"&id1&"' and name='"&name1&"'"
set rs_ = server.CreateObject("adodb.recordset")
rs_.open sql_,objconn,1,1
if rs_.recordcount<=0 then
rs_.close
'objconn.close
alert_error("数据异常!")
response.end
else
%>
<html>
<head>
<title>增加商家</title>
<link href="index.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<p align="center" class="one"><br>
修改———主力商家
<link href="index.css" rel="stylesheet" type="text/css">
<form enctype="multipart/form-data" method="post" action="xx3.asp">
<table width="86%" border="0" cellspacing="1" cellpadding="4" align="center" bordercolor="#333333">
<tr bgcolor="#FFCC66">
<td width="32%" height="29" bgcolor="#FFFFFF"> </td>
<td width="68%" bgcolor="#FFFFFF">商家名称:
<input name="nn" type="text" id="nn" value="<%=trim(rs_("name"))%>" size="40"> <br>
商家简介:
<textarea name="dd" cols="40" id="dd"><%=trim(rs_("description"))%></textarea> <br> <span class="one">商家地址:</span>
<input name="aa" type="text" id="aa" value="<%=trim(rs_("address"))%>" size="40"> <br>
联系电话:
<input name="tt" type="text" id="tt" value="<%=trim(rs_("tel"))%>" size="40"> <br>
传 真:
<input name="ff" type="text" id="ff" value="<%=trim(rs_("fax"))%>" size="40"> <br>
营业时间:
<input name="yy" type="text" id="yy" value="<%=trim(rs_("yydata"))%>" size="40"> <br>
店铺简图: <img src="<%=rs_("logo")%>" width="108" height="32" border="0"><br>
<input name="logo" type="file" id="logo"> <br> <br>
<input type="submit" name="Submit" value="增加"> </td>
</tr>
</table>
</form>
<%
end if
%>
<%
dim id1,name1
id1=trim(request("id"))
name1=trim(request("name"))
dim sql_
sql_="select * from jianjie where id='"&id1&"' and name='"&name1&"'"
set rs_ = server.CreateObject("adodb.recordset")
rs_.open sql_,objconn,1,1
if rs_.recordcount<=0 then
rs_.close
'objconn.close
alert_error("数据异常!")
response.end
else
%>
<html>
<head>
<title>增加商家</title>
<link href="index.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<p align="center" class="one"><br>
修改———主力商家
<link href="index.css" rel="stylesheet" type="text/css">
<form enctype="multipart/form-data" method="post" action="xx3.asp">
<table width="86%" border="0" cellspacing="1" cellpadding="4" align="center" bordercolor="#333333">
<tr bgcolor="#FFCC66">
<td width="32%" height="29" bgcolor="#FFFFFF"> </td>
<td width="68%" bgcolor="#FFFFFF">商家名称:
<input name="nn" type="text" id="nn" value="<%=trim(rs_("name"))%>" size="40"> <br>
商家简介:
<textarea name="dd" cols="40" id="dd"><%=trim(rs_("description"))%></textarea> <br> <span class="one">商家地址:</span>
<input name="aa" type="text" id="aa" value="<%=trim(rs_("address"))%>" size="40"> <br>
联系电话:
<input name="tt" type="text" id="tt" value="<%=trim(rs_("tel"))%>" size="40"> <br>
传 真:
<input name="ff" type="text" id="ff" value="<%=trim(rs_("fax"))%>" size="40"> <br>
营业时间:
<input name="yy" type="text" id="yy" value="<%=trim(rs_("yydata"))%>" size="40"> <br>
店铺简图: <img src="<%=rs_("logo")%>" width="108" height="32" border="0"><br>
<input name="logo" type="file" id="logo"> <br> <br>
<input type="submit" name="Submit" value="增加"> </td>
</tr>
</table>
</form>
<%
end if
%>
#5
修改的时候,先把图片路径读出来,根据路径显示图片。如果需要修改图片,那么就要在另一个文件处理。一般情况,上传图片时传递的是二进制数据。而通过表单提交传递的数据却不是。
注意:上传图片时的表单 ,的enctype值。
<form action="" method="post" enctype="multipart/form-data">
</form>
不过,我曾经在csdn好象看到过关于图片和图片信息同时提交的方法,你找找吧,我不记得在哪了?如果允许,还是建议你分开处理。
注意:上传图片时的表单 ,的enctype值。
<form action="" method="post" enctype="multipart/form-data">
</form>
不过,我曾经在csdn好象看到过关于图片和图片信息同时提交的方法,你找找吧,我不记得在哪了?如果允许,还是建议你分开处理。
#6
上传要修改的图片,文件名为要更改的图片的文件名。
不就行了么?
不就行了么?
#7
<!--#include file="inc/ConnectDatabase.inc"-->
<!--#include file="inc/cls_load.inc"-->
<!--#include file="inc/js_.inc"-->
<%
dim upload,upfile,sql
dim fromnn,fromdd,fromaa,fromtt,fromff,fromyy
set upload=new upload_5xSoft ''建立上传对象
'userid = session("userid")
'下面是获取前一页面中的input元素的方法,用upload.form来获取,相当于asp中的request.form
fromnn = upload.form("nn")
fromdd = upload.form("dd")
fromaa = upload.form("aa")
fromtt = upload.form("tt")
fromff = upload.form("ff")
fromyy = upload.form("yy")
set upload=new upload_5xsoft
'下面是用file对象来存储上一页面中的file控件的图片值,其中包括图片的路径,大小等等
set upfile=upload.file("logo")
if upfile.FileSize>0 then
if GetExtendName(upfile.FileName)<>"swf" and GetExtendName(upfile.FileName)<>"jpg" and GetExtendName(upfile.FileName)<>"gif" then
response.redirect("result.asp?msg=不是正确的图片格式。")
end if
end if
'sql="SELECT TOP 1 id,name,logo,description,address,tel,fax,yydata FROM jianjie order by id desc"
set rs=server.createobject("adodb.recordset")
rs.Open sql,objconn,1,2
while not rs.EOF
if trim(fromnn) = trim(rs("name")) then
rs.Close
'CloseConnection(objconn)
Alert_Back("此商家已经存在,请重新输入!")
Response.End
end if
rs.MoveNext
wend
'rs.addnew
rs("name")=fromnn
rs("description")=fromdd
rs("address")=fromaa
rs("tel")=fromtt
rs("fax")=fromff
rs("yydata")=fromyy
rs.update
rs.close()
rs.open sql,objconn,1,2
'response.write rs("id")
'response.End()
if upfile.FileSize>0 then
upfile.SaveAs Server.mappath("images/image"&rs("id")&"."&GetExtendName(upfile.FileName))
rs("logo") = "images/"&"image"&rs("id")&"."&GetExtendName(upfile.FileName)
rs.update
end if
'rs.close
'objconn.execute "insert into company (name,description) values('"&fromnn&"','"&fromdd&"')"
'objconn.close
'rs.close
response.Redirect("x1.asp")
function GetExtendName(FileName)//获取扩展名
dim ExtName
ExtName = LCase(FileName)
ExtName = right(ExtName,3)
ExtName = right(ExtName,3-Instr(ExtName,"."))
GetExtendName = ExtName
end function
%>
<!--#include file="inc/cls_load.inc"-->
<!--#include file="inc/js_.inc"-->
<%
dim upload,upfile,sql
dim fromnn,fromdd,fromaa,fromtt,fromff,fromyy
set upload=new upload_5xSoft ''建立上传对象
'userid = session("userid")
'下面是获取前一页面中的input元素的方法,用upload.form来获取,相当于asp中的request.form
fromnn = upload.form("nn")
fromdd = upload.form("dd")
fromaa = upload.form("aa")
fromtt = upload.form("tt")
fromff = upload.form("ff")
fromyy = upload.form("yy")
set upload=new upload_5xsoft
'下面是用file对象来存储上一页面中的file控件的图片值,其中包括图片的路径,大小等等
set upfile=upload.file("logo")
if upfile.FileSize>0 then
if GetExtendName(upfile.FileName)<>"swf" and GetExtendName(upfile.FileName)<>"jpg" and GetExtendName(upfile.FileName)<>"gif" then
response.redirect("result.asp?msg=不是正确的图片格式。")
end if
end if
'sql="SELECT TOP 1 id,name,logo,description,address,tel,fax,yydata FROM jianjie order by id desc"
set rs=server.createobject("adodb.recordset")
rs.Open sql,objconn,1,2
while not rs.EOF
if trim(fromnn) = trim(rs("name")) then
rs.Close
'CloseConnection(objconn)
Alert_Back("此商家已经存在,请重新输入!")
Response.End
end if
rs.MoveNext
wend
'rs.addnew
rs("name")=fromnn
rs("description")=fromdd
rs("address")=fromaa
rs("tel")=fromtt
rs("fax")=fromff
rs("yydata")=fromyy
rs.update
rs.close()
rs.open sql,objconn,1,2
'response.write rs("id")
'response.End()
if upfile.FileSize>0 then
upfile.SaveAs Server.mappath("images/image"&rs("id")&"."&GetExtendName(upfile.FileName))
rs("logo") = "images/"&"image"&rs("id")&"."&GetExtendName(upfile.FileName)
rs.update
end if
'rs.close
'objconn.execute "insert into company (name,description) values('"&fromnn&"','"&fromdd&"')"
'objconn.close
'rs.close
response.Redirect("x1.asp")
function GetExtendName(FileName)//获取扩展名
dim ExtName
ExtName = LCase(FileName)
ExtName = right(ExtName,3)
ExtName = right(ExtName,3-Instr(ExtName,"."))
GetExtendName = ExtName
end function
%>
#8
<%
'''''''''''''''''''''''''''''''''''''''''''''''''
'
'请保留此信息: 稻香老农制作,
'
'''''''''''''''''''''''''''''''''''''''''''''''''
dim upfile_5xSoft_Stream
Class upload_5xSoft
dim Form,File,Version
Private Sub Class_Initialize
dim iStart,iFileNameStart,iFileNameEnd,iEnd,vbEnter,iFormStart,iFormEnd,theFile
dim strDiv,mFormName,mFormValue,mFileName,mFileSize,mFilePath,iDivLen,mStr
Version=""
if Request.TotalBytes<1 or request.TotalBytes>204800 then
Response.Write "<script language=javascript>alert('请将图片大小限制在200K以下!');"
Response.Write "javascript:history.back();</script>"
Response.End
'/////////////////////
end if
'Exit Sub
'/////////////////////
set Form=CreateObject("Scripting.Dictionary")
set File=CreateObject("Scripting.Dictionary")
set upfile_5xSoft_Stream=CreateObject("Adodb.Stream")
upfile_5xSoft_Stream.mode=3
upfile_5xSoft_Stream.type=1
upfile_5xSoft_Stream.open
upfile_5xSoft_Stream.write Request.BinaryRead(Request.TotalBytes)
vbEnter=Chr(13)&Chr(10)
iDivLen=inString(1,vbEnter)+1
strDiv=subString(1,iDivLen)
iFormStart=iDivLen
iFormEnd=inString(iformStart,strDiv)-1
while iFormStart < iFormEnd
iStart=inString(iFormStart,"name=""")
iEnd=inString(iStart+6,"""")
mFormName=subString(iStart+6,iEnd-iStart-6)
iFileNameStart=inString(iEnd+1,"filename=""")
if iFileNameStart>0 and iFileNameStart<iFormEnd then
iFileNameEnd=inString(iFileNameStart+10,"""")
mFileName=subString(iFileNameStart+10,iFileNameEnd-iFileNameStart-10)
iStart=inString(iFileNameEnd+1,vbEnter&vbEnter)
iEnd=inString(iStart+4,vbEnter&strDiv)
if iEnd>iStart then
mFileSize=iEnd-iStart-4
else
mFileSize=0
end if
set theFile=new FileInfo
theFile.FileName=getFileName(mFileName)
theFile.FilePath=getFilePath(mFileName)
theFile.FileSize=mFileSize
theFile.FileStart=iStart+4
theFile.FormName=FormName
file.add mFormName,theFile
else
iStart=inString(iEnd+1,vbEnter&vbEnter)
iEnd=inString(iStart+4,vbEnter&strDiv)
if iEnd>iStart then
mFormValue=subString(iStart+4,iEnd-iStart-4)
else
mFormValue=""
end if
form.Add mFormName,mFormValue
end if
iFormStart=iformEnd+iDivLen
iFormEnd=inString(iformStart,strDiv)-1
wend
End Sub
Private Function subString(theStart,theLen)
dim i,c,stemp
upfile_5xSoft_Stream.Position=theStart-1
stemp=""
for i=1 to theLen
if upfile_5xSoft_Stream.EOS then Exit for
c=ascB(upfile_5xSoft_Stream.Read(1))
If c > 127 Then
if upfile_5xSoft_Stream.EOS then Exit for
stemp=stemp&Chr(AscW(ChrB(AscB(upfile_5xSoft_Stream.Read(1)))&ChrB(c)))
i=i+1
else
stemp=stemp&Chr(c)
End If
Next
subString=stemp
End function
Private Function inString(theStart,varStr)
dim i,j,bt,theLen,str
InString=0
Str=toByte(varStr)
theLen=LenB(Str)
for i=theStart to upfile_5xSoft_Stream.Size-theLen
if i>upfile_5xSoft_Stream.size then exit Function
upfile_5xSoft_Stream.Position=i-1
if AscB(upfile_5xSoft_Stream.Read(1))=AscB(midB(Str,1)) then
InString=i
for j=2 to theLen
if upfile_5xSoft_Stream.EOS then
inString=0
Exit for
end if
if AscB(upfile_5xSoft_Stream.write(1))<>AscB(MidB(Str,j,1)) then
InString=0
Exit For
end if
next
if InString<>0 then Exit Function
end if
next
End Function
Private Sub Class_Terminate
form.RemoveAll
file.RemoveAll
set form=nothing
set file=nothing
upfile_5xSoft_Stream.close
set upfile_5xSoft_Stream=nothing
End Sub
Private function GetFilePath(FullPath)
If FullPath <> "" Then
GetFilePath = left(FullPath,InStrRev(FullPath, "\"))
Else
GetFilePath = ""
End If
End function
Private function GetFileName(FullPath)
If FullPath <> "" Then
GetFileName = mid(FullPath,InStrRev(FullPath, "\")+1)
Else
GetFileName = ""
End If
End function
Private function toByte(Str)
dim i,iCode,c,iLow,iHigh
toByte=""
For i=1 To Len(Str)
c=mid(Str,i,1)
iCode =Asc(c)
If iCode<0 Then iCode = iCode + 65535
If iCode>255 Then
iLow = Left(Hex(Asc(c)),2)
iHigh =Right(Hex(Asc(c)),2)
toByte = toByte & chrB("&H"&iLow) & chrB("&H"&iHigh)
Else
toByte = toByte & chrB(AscB(c))
End If
Next
End function
End Class
Class FileInfo
dim FormName,FileName,FilePath,FileSize,FileStart
Private Sub Class_Initialize
FileName = ""
FilePath = ""
FileSize = 0
FileStart= 0
FormName = ""
End Sub
Public function SaveAs(FullPath)
dim dr,ErrorChar,i
SaveAs=1
if trim(fullpath)="" or FileSize=0 or FileStart=0 or FileName="" then exit function
if FileStart=0 or right(fullpath,1)="/" then exit function
set dr=CreateObject("Adodb.Stream")
dr.Mode=3
dr.Type=1
dr.Open
upfile_5xSoft_Stream.position=FileStart-1
upfile_5xSoft_Stream.copyto dr,FileSize
dr.SaveToFile FullPath,2
dr.Close
set dr=nothing
SaveAs=0
end function
End Class
%>
'''''''''''''''''''''''''''''''''''''''''''''''''
'
'请保留此信息: 稻香老农制作,
'
'''''''''''''''''''''''''''''''''''''''''''''''''
dim upfile_5xSoft_Stream
Class upload_5xSoft
dim Form,File,Version
Private Sub Class_Initialize
dim iStart,iFileNameStart,iFileNameEnd,iEnd,vbEnter,iFormStart,iFormEnd,theFile
dim strDiv,mFormName,mFormValue,mFileName,mFileSize,mFilePath,iDivLen,mStr
Version=""
if Request.TotalBytes<1 or request.TotalBytes>204800 then
Response.Write "<script language=javascript>alert('请将图片大小限制在200K以下!');"
Response.Write "javascript:history.back();</script>"
Response.End
'/////////////////////
end if
'Exit Sub
'/////////////////////
set Form=CreateObject("Scripting.Dictionary")
set File=CreateObject("Scripting.Dictionary")
set upfile_5xSoft_Stream=CreateObject("Adodb.Stream")
upfile_5xSoft_Stream.mode=3
upfile_5xSoft_Stream.type=1
upfile_5xSoft_Stream.open
upfile_5xSoft_Stream.write Request.BinaryRead(Request.TotalBytes)
vbEnter=Chr(13)&Chr(10)
iDivLen=inString(1,vbEnter)+1
strDiv=subString(1,iDivLen)
iFormStart=iDivLen
iFormEnd=inString(iformStart,strDiv)-1
while iFormStart < iFormEnd
iStart=inString(iFormStart,"name=""")
iEnd=inString(iStart+6,"""")
mFormName=subString(iStart+6,iEnd-iStart-6)
iFileNameStart=inString(iEnd+1,"filename=""")
if iFileNameStart>0 and iFileNameStart<iFormEnd then
iFileNameEnd=inString(iFileNameStart+10,"""")
mFileName=subString(iFileNameStart+10,iFileNameEnd-iFileNameStart-10)
iStart=inString(iFileNameEnd+1,vbEnter&vbEnter)
iEnd=inString(iStart+4,vbEnter&strDiv)
if iEnd>iStart then
mFileSize=iEnd-iStart-4
else
mFileSize=0
end if
set theFile=new FileInfo
theFile.FileName=getFileName(mFileName)
theFile.FilePath=getFilePath(mFileName)
theFile.FileSize=mFileSize
theFile.FileStart=iStart+4
theFile.FormName=FormName
file.add mFormName,theFile
else
iStart=inString(iEnd+1,vbEnter&vbEnter)
iEnd=inString(iStart+4,vbEnter&strDiv)
if iEnd>iStart then
mFormValue=subString(iStart+4,iEnd-iStart-4)
else
mFormValue=""
end if
form.Add mFormName,mFormValue
end if
iFormStart=iformEnd+iDivLen
iFormEnd=inString(iformStart,strDiv)-1
wend
End Sub
Private Function subString(theStart,theLen)
dim i,c,stemp
upfile_5xSoft_Stream.Position=theStart-1
stemp=""
for i=1 to theLen
if upfile_5xSoft_Stream.EOS then Exit for
c=ascB(upfile_5xSoft_Stream.Read(1))
If c > 127 Then
if upfile_5xSoft_Stream.EOS then Exit for
stemp=stemp&Chr(AscW(ChrB(AscB(upfile_5xSoft_Stream.Read(1)))&ChrB(c)))
i=i+1
else
stemp=stemp&Chr(c)
End If
Next
subString=stemp
End function
Private Function inString(theStart,varStr)
dim i,j,bt,theLen,str
InString=0
Str=toByte(varStr)
theLen=LenB(Str)
for i=theStart to upfile_5xSoft_Stream.Size-theLen
if i>upfile_5xSoft_Stream.size then exit Function
upfile_5xSoft_Stream.Position=i-1
if AscB(upfile_5xSoft_Stream.Read(1))=AscB(midB(Str,1)) then
InString=i
for j=2 to theLen
if upfile_5xSoft_Stream.EOS then
inString=0
Exit for
end if
if AscB(upfile_5xSoft_Stream.write(1))<>AscB(MidB(Str,j,1)) then
InString=0
Exit For
end if
next
if InString<>0 then Exit Function
end if
next
End Function
Private Sub Class_Terminate
form.RemoveAll
file.RemoveAll
set form=nothing
set file=nothing
upfile_5xSoft_Stream.close
set upfile_5xSoft_Stream=nothing
End Sub
Private function GetFilePath(FullPath)
If FullPath <> "" Then
GetFilePath = left(FullPath,InStrRev(FullPath, "\"))
Else
GetFilePath = ""
End If
End function
Private function GetFileName(FullPath)
If FullPath <> "" Then
GetFileName = mid(FullPath,InStrRev(FullPath, "\")+1)
Else
GetFileName = ""
End If
End function
Private function toByte(Str)
dim i,iCode,c,iLow,iHigh
toByte=""
For i=1 To Len(Str)
c=mid(Str,i,1)
iCode =Asc(c)
If iCode<0 Then iCode = iCode + 65535
If iCode>255 Then
iLow = Left(Hex(Asc(c)),2)
iHigh =Right(Hex(Asc(c)),2)
toByte = toByte & chrB("&H"&iLow) & chrB("&H"&iHigh)
Else
toByte = toByte & chrB(AscB(c))
End If
Next
End function
End Class
Class FileInfo
dim FormName,FileName,FilePath,FileSize,FileStart
Private Sub Class_Initialize
FileName = ""
FilePath = ""
FileSize = 0
FileStart= 0
FormName = ""
End Sub
Public function SaveAs(FullPath)
dim dr,ErrorChar,i
SaveAs=1
if trim(fullpath)="" or FileSize=0 or FileStart=0 or FileName="" then exit function
if FileStart=0 or right(fullpath,1)="/" then exit function
set dr=CreateObject("Adodb.Stream")
dr.Mode=3
dr.Type=1
dr.Open
upfile_5xSoft_Stream.position=FileStart-1
upfile_5xSoft_Stream.copyto dr,FileSize
dr.SaveToFile FullPath,2
dr.Close
set dr=nothing
SaveAs=0
end function
End Class
%>
#9
总是提示我这个文件有错误inc/cls_load.inc<%
'''''''''''''''''''''''''''''''''''''''''''''''''
'
'请保留此信息: 稻香老农制作,
'
'''''''''''''''''''''''''''''''''''''''''''''''''
dim upfile_5xSoft_Stream
Class upload_5xSoft
dim Form,File,Version
Private Sub Class_Initialize
dim iStart,iFileNameStart,iFileNameEnd,iEnd,vbEnter,iFormStart,iFormEnd,theFile
dim strDiv,mFormName,mFormValue,mFileName,mFileSize,mFilePath,iDivLen,mStr
Version=""
if Request.TotalBytes<1 or request.TotalBytes>204800 then
Response.Write "<script language=javascript>alert('请将图片大小限制在200K以下!');"
Response.Write "javascript:history.back();</script>"
Response.End
'/////////////////////
end if
'Exit Sub
'/////////////////////
set Form=CreateObject("Scripting.Dictionary")
set File=CreateObject("Scripting.Dictionary")
set upfile_5xSoft_Stream=CreateObject("Adodb.Stream")
upfile_5xSoft_Stream.mode=3
upfile_5xSoft_Stream.type=1
upfile_5xSoft_Stream.open
upfile_5xSoft_Stream.write Request.BinaryRead(Request.TotalBytes)
vbEnter=Chr(13)&Chr(10)
iDivLen=inString(1,vbEnter)+1
strDiv=subString(1,iDivLen)
iFormStart=iDivLen
iFormEnd=inString(iformStart,strDiv)-1
while iFormStart < iFormEnd
iStart=inString(iFormStart,"name=""")
iEnd=inString(iStart+6,"""")
mFormName=subString(iStart+6,iEnd-iStart-6)
iFileNameStart=inString(iEnd+1,"filename=""")
if iFileNameStart>0 and iFileNameStart<iFormEnd then
iFileNameEnd=inString(iFileNameStart+10,"""")
mFileName=subString(iFileNameStart+10,iFileNameEnd-iFileNameStart-10)
iStart=inString(iFileNameEnd+1,vbEnter&vbEnter)
iEnd=inString(iStart+4,vbEnter&strDiv)
if iEnd>iStart then
mFileSize=iEnd-iStart-4
else
mFileSize=0
end if
set theFile=new FileInfo
theFile.FileName=getFileName(mFileName)
theFile.FilePath=getFilePath(mFileName)
theFile.FileSize=mFileSize
theFile.FileStart=iStart+4
theFile.FormName=FormName
file.add mFormName,theFile
else
iStart=inString(iEnd+1,vbEnter&vbEnter)
iEnd=inString(iStart+4,vbEnter&strDiv)
if iEnd>iStart then
mFormValue=subString(iStart+4,iEnd-iStart-4)
else
mFormValue=""
end if
form.Add mFormName,mFormValue
end if
iFormStart=iformEnd+iDivLen
iFormEnd=inString(iformStart,strDiv)-1
wend
End Sub
Private Function subString(theStart,theLen)
dim i,c,stemp
upfile_5xSoft_Stream.Position=theStart-1
stemp=""
for i=1 to theLen
if upfile_5xSoft_Stream.EOS then Exit for
c=ascB(upfile_5xSoft_Stream.Read(1))
If c > 127 Then
if upfile_5xSoft_Stream.EOS then Exit for
stemp=stemp&Chr(AscW(ChrB(AscB(upfile_5xSoft_Stream.Read(1)))&ChrB(c)))
i=i+1
else
stemp=stemp&Chr(c)
End If
Next
subString=stemp
End function
Private Function inString(theStart,varStr)
dim i,j,bt,theLen,str
InString=0
Str=toByte(varStr)
theLen=LenB(Str)
for i=theStart to upfile_5xSoft_Stream.Size-theLen
if i>upfile_5xSoft_Stream.size then exit Function
upfile_5xSoft_Stream.Position=i-1
if AscB(upfile_5xSoft_Stream.Read(1))=AscB(midB(Str,1)) then
InString=i
for j=2 to theLen
if upfile_5xSoft_Stream.EOS then
inString=0
Exit for
end if
if AscB(upfile_5xSoft_Stream.write(1))<>AscB(MidB(Str,j,1)) then
InString=0
Exit For
end if
next
if InString<>0 then Exit Function
end if
next
End Function
Private Sub Class_Terminate
form.RemoveAll
file.RemoveAll
set form=nothing
set file=nothing
upfile_5xSoft_Stream.close
set upfile_5xSoft_Stream=nothing
End Sub
Private function GetFilePath(FullPath)
If FullPath <> "" Then
GetFilePath = left(FullPath,InStrRev(FullPath, "\"))
Else
GetFilePath = ""
End If
End function
Private function GetFileName(FullPath)
If FullPath <> "" Then
GetFileName = mid(FullPath,InStrRev(FullPath, "\")+1)
Else
GetFileName = ""
End If
End function
Private function toByte(Str)
dim i,iCode,c,iLow,iHigh
toByte=""
For i=1 To Len(Str)
c=mid(Str,i,1)
iCode =Asc(c)
If iCode<0 Then iCode = iCode + 65535
If iCode>255 Then
iLow = Left(Hex(Asc(c)),2)
iHigh =Right(Hex(Asc(c)),2)
toByte = toByte & chrB("&H"&iLow) & chrB("&H"&iHigh)
Else
toByte = toByte & chrB(AscB(c))
End If
Next
End function
End Class
Class FileInfo
dim FormName,FileName,FilePath,FileSize,FileStart
Private Sub Class_Initialize
FileName = ""
FilePath = ""
FileSize = 0
FileStart= 0
FormName = ""
End Sub
Public function SaveAs(FullPath)
dim dr,ErrorChar,i
SaveAs=1
if trim(fullpath)="" or FileSize=0 or FileStart=0 or FileName="" then exit function
if FileStart=0 or right(fullpath,1)="/" then exit function
set dr=CreateObject("Adodb.Stream")
dr.Mode=3
dr.Type=1
dr.Open
upfile_5xSoft_Stream.position=FileStart-1
upfile_5xSoft_Stream.copyto dr,FileSize
dr.SaveToFile FullPath,2
dr.Close
set dr=nothing
SaveAs=0
end function
End Class
%>
'''''''''''''''''''''''''''''''''''''''''''''''''
'
'请保留此信息: 稻香老农制作,
'
'''''''''''''''''''''''''''''''''''''''''''''''''
dim upfile_5xSoft_Stream
Class upload_5xSoft
dim Form,File,Version
Private Sub Class_Initialize
dim iStart,iFileNameStart,iFileNameEnd,iEnd,vbEnter,iFormStart,iFormEnd,theFile
dim strDiv,mFormName,mFormValue,mFileName,mFileSize,mFilePath,iDivLen,mStr
Version=""
if Request.TotalBytes<1 or request.TotalBytes>204800 then
Response.Write "<script language=javascript>alert('请将图片大小限制在200K以下!');"
Response.Write "javascript:history.back();</script>"
Response.End
'/////////////////////
end if
'Exit Sub
'/////////////////////
set Form=CreateObject("Scripting.Dictionary")
set File=CreateObject("Scripting.Dictionary")
set upfile_5xSoft_Stream=CreateObject("Adodb.Stream")
upfile_5xSoft_Stream.mode=3
upfile_5xSoft_Stream.type=1
upfile_5xSoft_Stream.open
upfile_5xSoft_Stream.write Request.BinaryRead(Request.TotalBytes)
vbEnter=Chr(13)&Chr(10)
iDivLen=inString(1,vbEnter)+1
strDiv=subString(1,iDivLen)
iFormStart=iDivLen
iFormEnd=inString(iformStart,strDiv)-1
while iFormStart < iFormEnd
iStart=inString(iFormStart,"name=""")
iEnd=inString(iStart+6,"""")
mFormName=subString(iStart+6,iEnd-iStart-6)
iFileNameStart=inString(iEnd+1,"filename=""")
if iFileNameStart>0 and iFileNameStart<iFormEnd then
iFileNameEnd=inString(iFileNameStart+10,"""")
mFileName=subString(iFileNameStart+10,iFileNameEnd-iFileNameStart-10)
iStart=inString(iFileNameEnd+1,vbEnter&vbEnter)
iEnd=inString(iStart+4,vbEnter&strDiv)
if iEnd>iStart then
mFileSize=iEnd-iStart-4
else
mFileSize=0
end if
set theFile=new FileInfo
theFile.FileName=getFileName(mFileName)
theFile.FilePath=getFilePath(mFileName)
theFile.FileSize=mFileSize
theFile.FileStart=iStart+4
theFile.FormName=FormName
file.add mFormName,theFile
else
iStart=inString(iEnd+1,vbEnter&vbEnter)
iEnd=inString(iStart+4,vbEnter&strDiv)
if iEnd>iStart then
mFormValue=subString(iStart+4,iEnd-iStart-4)
else
mFormValue=""
end if
form.Add mFormName,mFormValue
end if
iFormStart=iformEnd+iDivLen
iFormEnd=inString(iformStart,strDiv)-1
wend
End Sub
Private Function subString(theStart,theLen)
dim i,c,stemp
upfile_5xSoft_Stream.Position=theStart-1
stemp=""
for i=1 to theLen
if upfile_5xSoft_Stream.EOS then Exit for
c=ascB(upfile_5xSoft_Stream.Read(1))
If c > 127 Then
if upfile_5xSoft_Stream.EOS then Exit for
stemp=stemp&Chr(AscW(ChrB(AscB(upfile_5xSoft_Stream.Read(1)))&ChrB(c)))
i=i+1
else
stemp=stemp&Chr(c)
End If
Next
subString=stemp
End function
Private Function inString(theStart,varStr)
dim i,j,bt,theLen,str
InString=0
Str=toByte(varStr)
theLen=LenB(Str)
for i=theStart to upfile_5xSoft_Stream.Size-theLen
if i>upfile_5xSoft_Stream.size then exit Function
upfile_5xSoft_Stream.Position=i-1
if AscB(upfile_5xSoft_Stream.Read(1))=AscB(midB(Str,1)) then
InString=i
for j=2 to theLen
if upfile_5xSoft_Stream.EOS then
inString=0
Exit for
end if
if AscB(upfile_5xSoft_Stream.write(1))<>AscB(MidB(Str,j,1)) then
InString=0
Exit For
end if
next
if InString<>0 then Exit Function
end if
next
End Function
Private Sub Class_Terminate
form.RemoveAll
file.RemoveAll
set form=nothing
set file=nothing
upfile_5xSoft_Stream.close
set upfile_5xSoft_Stream=nothing
End Sub
Private function GetFilePath(FullPath)
If FullPath <> "" Then
GetFilePath = left(FullPath,InStrRev(FullPath, "\"))
Else
GetFilePath = ""
End If
End function
Private function GetFileName(FullPath)
If FullPath <> "" Then
GetFileName = mid(FullPath,InStrRev(FullPath, "\")+1)
Else
GetFileName = ""
End If
End function
Private function toByte(Str)
dim i,iCode,c,iLow,iHigh
toByte=""
For i=1 To Len(Str)
c=mid(Str,i,1)
iCode =Asc(c)
If iCode<0 Then iCode = iCode + 65535
If iCode>255 Then
iLow = Left(Hex(Asc(c)),2)
iHigh =Right(Hex(Asc(c)),2)
toByte = toByte & chrB("&H"&iLow) & chrB("&H"&iHigh)
Else
toByte = toByte & chrB(AscB(c))
End If
Next
End function
End Class
Class FileInfo
dim FormName,FileName,FilePath,FileSize,FileStart
Private Sub Class_Initialize
FileName = ""
FilePath = ""
FileSize = 0
FileStart= 0
FormName = ""
End Sub
Public function SaveAs(FullPath)
dim dr,ErrorChar,i
SaveAs=1
if trim(fullpath)="" or FileSize=0 or FileStart=0 or FileName="" then exit function
if FileStart=0 or right(fullpath,1)="/" then exit function
set dr=CreateObject("Adodb.Stream")
dr.Mode=3
dr.Type=1
dr.Open
upfile_5xSoft_Stream.position=FileStart-1
upfile_5xSoft_Stream.copyto dr,FileSize
dr.SaveToFile FullPath,2
dr.Close
set dr=nothing
SaveAs=0
end function
End Class
%>
#10
分两步:1、修改图片其他信息,通过表单。
2、图片上传,同时自动修改数据库图片名。
2、图片上传,同时自动修改数据库图片名。
#11
错误提示:Microsoft VBScript 编译器错误 错误 '800a03f6'
缺少 'End'
/iisHelp/common/500-100.asp,行242
ADODB.Stream 错误 '800a0bb9'
变量或者类型不正确,或者不在可以接受的范围之内,要不就是与其他数据冲突。
/elegance/back/inc/cls_load.inc,行33
缺少 'End'
/iisHelp/common/500-100.asp,行242
ADODB.Stream 错误 '800a0bb9'
变量或者类型不正确,或者不在可以接受的范围之内,要不就是与其他数据冲突。
/elegance/back/inc/cls_load.inc,行33
#12
各位帮帮忙呀!!!
#13
通过一下的两个函数可以实现图片,文字的同时提交处理。
Function BinaryToString(str)
strto = ""
for i=1 to lenb(str)
if AscB(MidB(str, i, 1)) > 127 then
strto = strto & chr(Ascb(MidB(str, i, 1))*256+Ascb(MidB(str, i+1, 1)))
i = i + 1
else
strto = strto & Chr(AscB(MidB(str, i, 1)))
end if
next
BinaryToString=strto
End Function
function gainformdata(n)
dim formsize,formdata,divider,datastart,dataend
redim mydata(n-1)
formsize = Request.TotalBytes
formdata = Request.BinaryRead(formsize)
for i=1 to n
bncrlf = chrB(13) & chrB(10)
divider = leftB(formdata,clng(instrB(formdata,bncrlf))-1)
datastart = instrB(formdata,bncrlf & bncrlf)+4
dataend = instrB(datastart+1,formdata,divider) - datastart-2
mydata(i-1) = midB(formdata,datastart,dataend)
formdata=rightB(formdata,clng(formsize-instrB(datastart+1,formdata,divider))+1)
formsize=lenB(formdata)
next
gainformdata=mydata
end function
Demo:
a.htm:
<form name="form1" method="post" action="b.asp" enctype="multipart/form-data">
<textarea name="txt"></textarea>
<input type="file" name="file">
<input type="submit" name="Submit" value="提交">
</form>
b.asp:
'链接数据库
data=gainfromdata(2)
rs("txt")=binarytostring(data(0))
rs("img").appendchunk=data(1)
用ASP实现无组件上传/下载文件
'
' 功能简介
' 将上传的文件数据保存到数据库中,可以处理表单中的多个上传文件的情况
' 适用于各种数据库,使用ADO的方法连接数据库
' 本示例中使用的是ACCESS数据库:zj.mdb
' 表:tb_img(id int(自增列),path text(255) 保存上传文件的目录
' ,fname text(250) 保存上传的文件名,type test(250) 保存上传文件的类型
' ,img ole对象 保存上传的文件内容
'
' 邹建 2003.10
'==================================================================
'==================================================================
'
' 上传文件的HTML页: zj_up.htm
'
'==================================================================
<html>
<head>
<title>文件上传保存到数据库中</title>
</head>
<body>
<form name="form1" enctype="multipart/form-data" method="post" action="zj_up.asp">
<p>
<input type="file" name="file">
<input type="submit" name="Submit" value="上传">
</p>
</form>
</body>
</html>
Function BinaryToString(str)
strto = ""
for i=1 to lenb(str)
if AscB(MidB(str, i, 1)) > 127 then
strto = strto & chr(Ascb(MidB(str, i, 1))*256+Ascb(MidB(str, i+1, 1)))
i = i + 1
else
strto = strto & Chr(AscB(MidB(str, i, 1)))
end if
next
BinaryToString=strto
End Function
function gainformdata(n)
dim formsize,formdata,divider,datastart,dataend
redim mydata(n-1)
formsize = Request.TotalBytes
formdata = Request.BinaryRead(formsize)
for i=1 to n
bncrlf = chrB(13) & chrB(10)
divider = leftB(formdata,clng(instrB(formdata,bncrlf))-1)
datastart = instrB(formdata,bncrlf & bncrlf)+4
dataend = instrB(datastart+1,formdata,divider) - datastart-2
mydata(i-1) = midB(formdata,datastart,dataend)
formdata=rightB(formdata,clng(formsize-instrB(datastart+1,formdata,divider))+1)
formsize=lenB(formdata)
next
gainformdata=mydata
end function
Demo:
a.htm:
<form name="form1" method="post" action="b.asp" enctype="multipart/form-data">
<textarea name="txt"></textarea>
<input type="file" name="file">
<input type="submit" name="Submit" value="提交">
</form>
b.asp:
'链接数据库
data=gainfromdata(2)
rs("txt")=binarytostring(data(0))
rs("img").appendchunk=data(1)
用ASP实现无组件上传/下载文件
'
' 功能简介
' 将上传的文件数据保存到数据库中,可以处理表单中的多个上传文件的情况
' 适用于各种数据库,使用ADO的方法连接数据库
' 本示例中使用的是ACCESS数据库:zj.mdb
' 表:tb_img(id int(自增列),path text(255) 保存上传文件的目录
' ,fname text(250) 保存上传的文件名,type test(250) 保存上传文件的类型
' ,img ole对象 保存上传的文件内容
'
' 邹建 2003.10
'==================================================================
'==================================================================
'
' 上传文件的HTML页: zj_up.htm
'
'==================================================================
<html>
<head>
<title>文件上传保存到数据库中</title>
</head>
<body>
<form name="form1" enctype="multipart/form-data" method="post" action="zj_up.asp">
<p>
<input type="file" name="file">
<input type="submit" name="Submit" value="上传">
</p>
</form>
</body>
</html>