📄 instructor_modify_deal.asp
字号:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<!--#include file="Conn/Conn.asp"-->
<%
'获得荣誉信息
Response.Buffer=true
formsize=Request.TotalBytes
formdata=Request.BinaryRead(formsize)
crlf=chrB(13)&chrB(10)
strflag=leftb(formdata,clng(instrb(formdata,crlf))-1)
'修改荣誉信息到数据库
'获得表单所有元素的值
k = 1
While instrb(k,formdata,strflag) < instrb((instrb(k,formdata,strflag)+lenb(strflag)),formdata,strflag)
start = instrb(k,formdata,strflag) + lenb(strflag) + 2
endsize = instrb((instrb(k,formdata,strflag)+lenb(strflag)),formdata,strflag) - start - 2
bin_content = midb(formdata,start,endsize)
pos1_name = instrb(bin_content,toByte("name="""))
pos2_name = instrb(pos1_name+6,bin_content,toByte(""""))
nametag = midb(bin_content,pos1_name+6,pos2_name-pos1_name-6)
pos1_filename = instrb(pos2_name,bin_content,toByte("filename="""))
If(pos1_filename = 0)Then
namevalue = toStr(midb(bin_content,pos2_name+5,lenb(bin_content)-pos2_name-4))
If(InStr(toStr(nametag),"HID") > 0)Then
Sql = "Select * from tb_instructor Where ID="&namevalue
Set rs = Server.CreateObject("ADODB.Recordset")
rs.open Sql,conn,1,3
nowID=namevalue
End If
If(InStr(toStr(nametag),"Title") > 0)Then
'判断用户输入的信息是否存在
Set rs_if=Server.CreateObject("ADODB.RecordSet")
sql_if="Select * From tb_instructor Where title='"&namevalue&"' and ID<>"&nowID
rs_if.Open sql_if,conn,1,3
If rs_if.eof or rs_if.bof Then
rs.update "Title",namevalue
Else %>
<script language="javascript">
alert("该信息已经存在,请重新输入!");
history.back();
</script>
<%Response.End()
End If
End If
Else
'取filename的值
pos2_filename = instrb(pos1_filename+10,bin_content,toByte(""""))
fullpath = midb(bin_content,pos1_filename+10,pos2_filename-pos1_filename-10)
If(fullpath <> "")Then
'判断上传的格式
filename = GetFileName(toStr(fullpath))
expandname = Mid(filename,InStrRev(filename,".")+1)
imgarray = Array("gif","jpg","jpeg","jpe")
imgflag = false
For q=0 To Ubound(imgarray)
If(InStr(Lcase(expandname),imgarray(q)) > 0)Then
imgflag = true
End If
Next
If(imgflag = false)Then
%>
<script>
alert("上传格式不对!");
history.go(-1);
</script>
<%
Response.End()
End If
'获得上传图片的二进制数据
bin_start = instrb(filename,crlf&crlf) + 4
filedata=midb(filename,bin_start)
If(LenB(filedata) = 0)Then
%>
<script>
alert("上传的图片不存在!");
history.go(-1);
</script>
<%
Response.End()
End If
instreampos = instrb(start,formdata,crlf&crlf) + 3
If(Round(LenB(filedata)/1024,0) > 150)Then
%>
<script>
alert("大小不得超过150K!");
history.go(-1);
</script>
<%
Response.End()
End If
bin_start = instrb(bin_content,crlf&crlf) + 4
filedata=midb(bin_content,bin_start)
rs("Img").AppendChunk filedata '将图片以二进制格式保存到数据库中
End If
End If
k = instrb((instrb(k,formdata,strflag)+lenb(strflag)),formdata,strflag)
Wend
rs.Update
rs.Close
Set rs = Nothing
%>
<script language="javascript">
alert("数据修改成功!");
window.location.href="Instructor.asp";
</script>
<%
Response.End()
'字符串转换成二进制数
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
'二进制转换成字符串
Private function toStr(Byt)
toStr=""
for i=1 to lenb(byt)
blow = midb(byt,i,1)
if ascb(blow)>127 then
toStr = toStr&chr(ascw(midb(byt,i+1,1)&blow)) '这里浪费了挺多的时间。
i = i+1
else
toStr = toStr&chr(ascb(blow))
end if
Next
End function
'获得上传文件的路径
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
'获取上传名字
Function UpName()
Dim TimValue,Temp,RndValue
TimValue = Now()
Temp = Year(TimValue)&Month(TimValue)&Day(TimValue)&Hour(TimValue)&Minute(TimValue)&Second(TimValue)
UpName = Temp
End Function
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -