| asp实现语音上传 |
| 作者:佚名 来源:不详 发布时间:2007-9-18 22:47:54 |
|
<script language="javascript">
function openScript(url, width, height){ var Win = window.open(url,"openScript",'width=' + width + ',height=' + height + ',resizable=1,scrollbars=yes,menubar=no,status=yes' ); } </script>
<form action="save.asp" method="POST" enctype="multipart/form-data"> <tr> <td width="17%" height="66">选择语音</td> <td height="66" colspan="5"> <input type="file" name="wav" class="lan"> <input type="submit" name="Submit4" value="确定上传" class="lan"> <input name="button" type="button" class="bu" value="有声档案" id")%>','','scrollbars=no,resizable=no,width=340,height=200')"></td> </tr> </form> 表 sound 字段 id numeric 9 (自增) wav image 16 wavinfo varchar 50 wavsize numeric save.asp '将声音文件写入数据库
<%@ Language=VBScript %> <!--#include file="../conn.asp" <% Response.expires=0 Server.ScriptTimeout =3600
call main()
sub main()
FormSize = Request.TotalBytes FormData = Request.BinaryRead( FormSize )
bncrlf=chrb(13) & chrb(10) divider=leftb(FormData,instrb(FormData,bncrlf)-1) datastart=instrb(FormData,bncrlf & bncrlf)+4 dataend=instrb(datastart+1,formdata,divider)-datastart
Wav = WavUp(FormSize,Formdata)
strTXT=mid(formdata,instr(formdata,Wav)+len(Wav)+1) strTXT=bin2str(strTXT)
'wavinfo=findVar("wavinfo",strTXT)
set RS=server.createobject("ADODB.recordset") SQL="select wav,wavsize,wavinfo from sound" RS.Open SQL,conn,1,3
RS.Addnew RS("wavinfo")=wavinfo RS("wavsize")=dataend-2 if Len(Wav)>1 then RS("wav").Appendchunk Wav end if RS.Update RS.Close set RS=nothing conn.close set conn=nothing 'response.Write(Request.ServerVariables ("REMOTE_ADDR")) response.Write("<script language='javascript'>alert('语音上传成功了,请返回!');window.location.reload('sound.asp');</script>") response.end end sub
Function bin2str(binstr) Dim varlen,clow,ccc,skipflag skipflag=0 ccc = "" varlen=LenB(binstr) For i=1 To varlen If skipflag=0 Then clow = MidB(binstr,i,1) If AscB(clow) > 127 Then ccc =ccc & Chr(AscW(MidB(binstr,i+1,[1] [2] [3] 下一页 2007-9-18 22:47:54免费资源duzhi.net |
|
|
|
|
|
|
| [
]
[返回上一页]
[打 印] |
|
【笃志小屋duzhi.net】 |
|
|
技术文章导航 |
|
|
技术文章排行 |
|
|
精彩推荐 |
|
|
|