【asp源码栏目提醒】:网学会员鉴于大家对asp源码十分关注,论文会员在此为大家搜集整理了“ASP学习经验 - 医学卫生”一文,供大家参考学习
ASP一个网络U盘的代码 主文件 lthtmlgt ltheadgt lttitlegt上传文件页面lt/titlegt ltstylegt body font-size:9pt td font-size:9pt input font-size:9pt textarea font-size:9pt lt/stylegt ltscript languageJscriptgt function checkSubsrc ifsrc.filename.value alertquot文件主题必须输入quot src.filename.focus return false ifsrc.fruit.value alertquot请选择要上传的文件quot src.fruit.focus return false lt/scriptgt ltlink hrefquot../css/index.cssquot typequottext/cssquot relquotstylesheetquotgt lt/headgt ltbody stylemargin:0background:FFFFFF gt lttable width680 border0 aligncenter cellpaddingquot8quot cellspacingquot1quot bgcolorquotEAEAEAquot stylequotmargin-top:15pxquotgt lttr height100 gt lttd heightquot45quot classquottxt_bgquot gt 我 的 硬 盘lt/tdgt lt/trgt lttrgt lttd valigntop bgcolorFFFFFFgtltbrgt ampnbspampnbspltimg srcquot../image/v1.gifquot widthquot9quot heightquot9quotgt 文件列表:ltbrgt lthr size0 width96 aligncenter colorquotD8D8D8quotgt lttable border0 width90 aligncenter cellspacingquot2quot cellpaddingquot0quotgt lt Dim Sql Dim Rs Sqlquotselect top 100 from upfile_table where user_namequotampsessionquotuser_namequotampquot order by id descquot set RsServer.CreateObjectquotAdodb.Recordsetquot Rs.Open Sqlconn11 if not Rs.EOF then while not Rs.EOF Response.Write quotlttr height20gtlttd width6 nowrapgt主题:lt/tdgtlttdgtltimg src../image/v2.gif gt ltbgtquotamp RsquotSubjectquot ampquot lt/bgt IDquotamp Rsquotuser_namequot ampquot 大小quotamp Rsquotfilesizequot ampquot 字节ampnbspampnbsp时间quotamp Rsquotaddtimequot ampquotlt/tdgtlt/trgtquot Response.Write quotlttr height20gtlttd width6 nowrapgt文件:lt/tdgtlttdgtlta hrefquotamp RsquotfilePathquot ampquot/quotamp RsquotFilenamequot ampquot target_blankgtquotamp RsquotFilenamequot ampquotlt/agtlt/tdgtlt/trgtquot Response.Write quotlttr height20gtlttd width6 nowrapgt简介:lt/tdgtlttdgtquotamp RsquotExpitquot ampquotlt/tdgtlt/trgtquot Response.Write quotlttr height1 bgcoloreeeeeegtlttd colspan2gtlt/tdgtlt/trgtquot Rs.MoveNext wend else Response.Write quotlttrgtlttdgt无记录lt/tdgtlt/trgtquot end if Rs.Close gt lt/tablegt lt/tdgt lt/trgt lt/tablegt ltbrgt lttable widthquot680quot borderquot0quot alignquotcenterquot cellpaddingquot0quot cellspacingquot1quot bgcolorquotE3E3E3quotgt lttrgt lttd heightquot25quot bgcolorFFFFFFgt ltdiv alignquotleftquot stylequotheight:30px padding-top:10pxquotgt ampnbsp该页面设定可上传文件大小为ltfont colorredgt 5M lt/fontgt以下lt/divgt lttable widthquot100quot border0 alignquotcenterquot cellpaddingquot5quotgt ltform methodquotPOSTquot actionquotadmin_upfile.aspquot enctypequotmultipart/form-dataquot idquotform1quot namequotform1quot onsubmitreturn checkSubthisgt ltinput nameerrnumber typehidden value0 checked gt lttrgt lttdgt所属用户lt/tdgt lttd colspanquot2quotgt lt set Rs2Server.CreateObjectquotAdodb.Recordsetquot sqlquotselect from user order by user_id descquot rs2.open sqlconn13 if not rs2.eof then gt ltwhile not rs2.eofgt ltoption valuequotltrs2quotuser_namequotgtquotgtltrs2quotuser_namequotgtlt/optiongt lt rs2.movenext wend gtlt/selectgt lt end if rs2.close gtlt/tdgt lt/trgt lttrgt lttd widthquot11quotgt主题lt/tdgt lttd colspanquot2quotgtltinput typetext namefilename size50gtlt/tdgt lt/trgt lttrgt lttdgt文件lt/tdgt lttd colspanquot2quotgtltinput typequotfilequot namequotfruitquot sizequot50quot classquotgo-wenbenkuang2quotgtlt/tdgt lt/trgt lttrgt lttd valigntopgt简介lt/tdgt lttd colspanquot2quotgtlttextarea namefileExt cols50 rows10gtlt/textareagtlt/tdgt lt/trgt lttrgt lttd alignquotcenterquotgtampnbsplt/tdgt lttd widthquot54quot alignquotcenterquotgtltinput typequotsubmitquot valuequot上传文件quot namequotsubbuttquot classquotgo-wenbenkuangquotgtlt/tdgt lttd widthquot35quot alignquotcenterquotgtampnbsplt/tdgt lt/trgt lt/formgt lt/tablegt ltdiv alignquotcenterquotgtlt/divgt lt/tdgt lt/trgt lt/tablegt lt/bodygt lt/htmlgt 上传文件 lt--include filequotuploadx.aspquot--gt lt--include filequot../inc/admin_conn.aspquot--gt lthtmlgt ltheadgt lttitlegt上传文件中.....lt/titlegt lt/headgt ltbodygt lt Dim filePath Dim fileName Dim fileExt Dim file_subject Dim Sql Dim msg Dim errflag Dim errnumber Dim SavePath Dim maxfilesize Dim user_name SavePath quotSavePathquot 虚拟路径后面不要加quot/quot符号 maxfilesize 15120 大小为5M Errflagfalse filePath SavePath 使用虚拟路径进行赋值如quot/wwwquot或quotwwwquot等 filePath Server.MapPathfilePath 将虚拟路径转换为磁盘路径 file_subject GetFormValquotfilenamequot 取得文件标题 fileext GetFormValquotfileExtquot 取得文件介绍 errnumber GetFormValquoterrnumberquot 取得报错方式 errnumber cinterrnumber if lentrimfile_subject0 then Response.Write quot文件主题不能为空quot Response.End end if if lentrimfileext0 then fileext quot无简介quot end if filename SaveFilequotfruitquotfilePathmaxfilesizeerrnumber1 保存并取得文件名 01 唯一文件名方式如果有同名则自动改名 11 报错方式如果有同名则出错 201 覆盖方式如果有同名则覆盖原来的文件 if lentrimfilenamegt0 then Dim PerFnN Dim intPerFnN Dim PerFsize PerFnNsplitfilenamequotquot intPerFnNUboundPerFnN Select Case intPerFnN Case 1 FileNameTrimPerFnN0 PerFsizeCsngTrimPerFnN1 Case 0 FileNameTrimPerFnN0 PerFsize0 End Select select case Trimfilename case quotpathErrorquot msgquot错误: 指定的路径不存在quot errflagtrue case quotrefileErrorquot msgquot错误: 文件已经存在quot errflagtrue cas msgquot错误: 文件超出指定大小quot errflagtrue case quotmodeErrorquot msgquot主机在不支持Fso模式下不能采用唯一或报错方式上传文件quot errflagtrue case quotfileErrorquot msgquot被限制上传的文件格式quot errflagtrue case else msgquotquot errflagfalse end select if not errflag then Sql quotinsert into upfile_table subjectexpitfilepathfilenameuser_namefilesizeaddtime valuesquot Sql Sqlamp quot quotamp file_subject ampquotquotamp fileext ampquotquotamp SavePath ampquotquotamp filename ampquotquotamp sessionquotuser_namequot ampquotquotamp PerFsize ampquotquotampnowampquotquot conn.executesql end if end if conn.close set connnothing Response.Write quotltscript languageJscriptgtquotampvbcrlf Response.Write quotlt--quotampvbcrlf if errflag then Response.Write quotalertquotamp msg ampquotquotampvbcrlf end if Response.Write quotalert上传成功window.location.hrefadmin_index.aspquot Response.Write quot//--gtquotampvbcrlf Response.Write quotlt/scriptgtquotampvbcrlf gt lt/bodygt lt/htmlgt 2uploadx.asp lt 程序名Program Name: Allyes 无组件上传程序 功能Function 1.可自行设定上传文件大小 2.可自行根据主机Fso状态设置Fso的支持状态 3.可自行设定保存文件的方式0唯一方式1报错方式2覆盖方式 作者Author: Allyes·Mac 最后修改日期The Date for last Modify:2003年6月21日 版本Version: 1.003 build 205 修改Modify: 1、添加了显示文件大小Build 204升级为Build 205 2、添加了上传文件格式限制Build 203 升级为Build 204 使用方式Option: 将上传的文件保存到path所指定的目录下面。