setlocal enabledelayedexpansion
::kzm后写上文件扩展名
set kzm=.txt
::wjm是你指定的文件名
set wjm=文本文件
for /f "delims=" %%i in ('dir /a-d /b *!kzm!') do (
set /a i+=1
ren "%%i" !wjm!!i!!kzm!
)
<table width="780" border="0" align="center" bgcolor="#BBD1E8"><tr><td height="28" align="center"><!--#include file="images/logo.jpg"--></td></tr></table>
<!--#include FILE="images/yancd.cn.inc"-->
<%
set upload=new upload_5xsoft
for each formName in upload.File
set file=upload.file(formName)
if file.filesize>cint(uploadsize)*500 then '500单位为字节,要改多少,把数字改了就行了。
HtmEnd "文件大小超过了限制。"
set upload=nothing
response.end
end if
set file=upload.file("file1")
kzm=right(file.filename,4)
name="img/" &year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&kzm
if file.fileSize>0 Then
If kzm<>".gif" And kzm<>".jpg" Then
response.Write("<script language=javascript>alert('只支持“.gif”和“.jpg”文件类型的图片上传!')history.go(-1)</script>")
else
file.SaveAs Server.mappath(name)
set conn=server.createobject("adodb.connection")
connstr="Provider=Microsoft.jet.oledb.4.0data source="&server.mappath("images/yancd.cn.asp")
conn.open connstr
set rs=server.createobject("adodb.recordset")
sql="select * from pic"
rs.open sql,conn,1,3
rs.addnew
rs("name")=name
rs("classid")=upload.form("classid")
rs("pic_name")=upload.form("pic_name")
rs.update
rs.close
set rs=nothing
conn.close
set rs=Nothing
Response.Redirect "index.asp?page=1&"&"classid="&classid
End If
end If
set file=nothing
set upload=Nothing
%>
<SCRIPT language=JavaScript>
function CheckForm()
{
if (document.form1.classid.value.length == 0)
{
alert("请选择图片类别!")
document.form1.classid.focus()
return false
}
if (document.form1.pic_name.value.length == 0)
{
alert("请填写图片名称!")
document.form1.pic_name.focus()
return false
}
}
</script>
if (FileUpload1.HasFile){
string kzm = System.IO.Path.GetExtension(FileUpload1.FileName).ToLower()
if (kzm != ".jpg" &&kzm != ".bmp" &&kzm != ".gif" &&kzm != ".png")
throw new Exception("请选择jpg,bmp,gif,png的图片格式!")
xwxx.tplx = kzm
}
把if里的条件改一下就行了,就是判断的后缀名
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)