asp图⽚上传源码【亲测】
<!--#include virtual="/website/blog/include/upload_5xsoft.inc"-->
<%
dim upload,file,formName,formPath,iCount
set upload=new upload_5xsoft ''建⽴上传对象
set file=upload.file("UserPic")
formPath="/website/blog/userpic/"
if file.fileSize>0 then
''判断图⽚⼤⼩
if file.filesize>200000 then
response.write"<SCRIPT language=JavaScript>alert('您上传的图⽚⼤于规定⼤⼩(200K),请改变⽂件⼤⼩后再进⾏上传。');" response.write"(-1)</SCRIPT>"
else
end if
''判断图⽚的类型
FileExt = Mid(file.Filename, InStrRev(file.Filename, ".")+1)
if trim(right(file.FileName,3))<>"jpg" and trim(right(file.FileName,3))<>"gif" and trim(right(file.FileName,3))<>"JPG" then
response.write"<SCRIPT language=JavaScript>alert('您上传的⽂件必须是gif|jpg|jpeg图象⽂件,请将你上传的⽂件转换为以上格式后再进⾏上传。');"
response.write"(-1)</SCRIPT>"
end if
Furl=year(now())&month(now())&day(now())&hour(now())&minute(now())&second(now())
thename=session("username")&Furl&"."&FileExt
file.saveAs Server.mappath(formPath&thename)
picurl=formPath&thename
end if
set file=nothing
set upload=nothing
addsql="update kexue_admin set pic='"&picurl&"' where admin_name='"&session("username")&"'"
'response.Write addsql
'response.End()
set objRecordset=server.CreateObject("ADODB.Recordset")
objRecordset.open addsql,conn,3,1
If Err.Number = 0 Then
%>
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论