ASP上传文件名的命名规则.
<%@LANGUAGE="VBSCRIPT"CODEPAGE="936"%><%Server.ScriptTimeout=999%><!--#includefile="s...
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%Server.ScriptTimeout=999%>
<!--#include file="stone_Upload.asp" -->
<!-- 上传开始 -->
<%
if request("action")="upfile" then
set upload=new upload_5xsoft
set file=upload.file("s_file")
fileExt=lcase(right(file.filename,4))
if fileEXT<>".rar" and fileEXT<>".rar" and fileEXT<>".rar" then '文件格式
response.write"<script>alert('文件格式不对,请重新上传!');location='"&request.ServerVariables("HTTP_REFERER")&"'</script>"
response.end
end if
if file.fileSize>0 then
'if file.fileSize>1000*1024 then'限制大小
'else
formPath="uploadfile/soft" '上传路径,必须手动建立文件夹
if right(formPath,1)<>"/" then
formPath=formPath&"/"
end if
vfname = filename(now())
fname = vfname & "." & GetExtendName(file.FileName)
file.SaveAs Server.mappath(formPath&fname) ''保存文件
%>
<script>
//这里设置form的名字,和input的名字
parent.myform.pic.value='uploadfile/soft/<%=fname%>'
location.replace('stone_upsoft.asp')
</script>
<%
end if
set file=nothing
set upload=nothing
function filename(fname)
fname = now()
fname = replace(fname,"-","")
fname = replace(fname," ","")
fname = replace(fname,":","")
fname = replace(fname,"PM","")
fname = replace(fname,"AM","")
fname = replace(fname,"上午","")
fname = replace(fname,"下午","")
filename=fname
end function
function GetExtendName(FileName)
dim ExtName
ExtName = LCase(FileName)
ExtName = right(ExtName,3)
ExtName = right(ExtName,3-Instr(ExtName,"."))
GetExtendName = ExtName
end function
end if
%>
<!-- 上传结束 -->
问题: 我想让它上传后文件名保持在我本地时的名字,怎么改? 展开
<%Server.ScriptTimeout=999%>
<!--#include file="stone_Upload.asp" -->
<!-- 上传开始 -->
<%
if request("action")="upfile" then
set upload=new upload_5xsoft
set file=upload.file("s_file")
fileExt=lcase(right(file.filename,4))
if fileEXT<>".rar" and fileEXT<>".rar" and fileEXT<>".rar" then '文件格式
response.write"<script>alert('文件格式不对,请重新上传!');location='"&request.ServerVariables("HTTP_REFERER")&"'</script>"
response.end
end if
if file.fileSize>0 then
'if file.fileSize>1000*1024 then'限制大小
'else
formPath="uploadfile/soft" '上传路径,必须手动建立文件夹
if right(formPath,1)<>"/" then
formPath=formPath&"/"
end if
vfname = filename(now())
fname = vfname & "." & GetExtendName(file.FileName)
file.SaveAs Server.mappath(formPath&fname) ''保存文件
%>
<script>
//这里设置form的名字,和input的名字
parent.myform.pic.value='uploadfile/soft/<%=fname%>'
location.replace('stone_upsoft.asp')
</script>
<%
end if
set file=nothing
set upload=nothing
function filename(fname)
fname = now()
fname = replace(fname,"-","")
fname = replace(fname," ","")
fname = replace(fname,":","")
fname = replace(fname,"PM","")
fname = replace(fname,"AM","")
fname = replace(fname,"上午","")
fname = replace(fname,"下午","")
filename=fname
end function
function GetExtendName(FileName)
dim ExtName
ExtName = LCase(FileName)
ExtName = right(ExtName,3)
ExtName = right(ExtName,3-Instr(ExtName,"."))
GetExtendName = ExtName
end function
end if
%>
<!-- 上传结束 -->
问题: 我想让它上传后文件名保持在我本地时的名字,怎么改? 展开
展开全部
vfname = filename(now())
fname = vfname & "." & GetExtendName(file.FileName)
file.SaveAs Server.mappath(formPath&fname) ''保存文件
改成以下代码
vfname = file.FileName
fname = vfname & "." & GetExtendName(file.FileName)
file.SaveAs Server.mappath(formPath&fname) ''保存文件
fname = vfname & "." & GetExtendName(file.FileName)
file.SaveAs Server.mappath(formPath&fname) ''保存文件
改成以下代码
vfname = file.FileName
fname = vfname & "." & GetExtendName(file.FileName)
file.SaveAs Server.mappath(formPath&fname) ''保存文件
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询