上传文件,如何获取原文件名?

liuyingzi 2005-03-24 11:50:35
上传文件,如何获取原文件名?
我不想用其他文件名,还想用原来的文件名
...全文
1010 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
lonkil 2005-03-25
  • 打赏
  • 举报
回复
在上传文件中,用script取得
chenqishanghai 2005-03-25
  • 打赏
  • 举报
回复
up
yangtututu 2005-03-25
  • 打赏
  • 举报
回复
up
dirib 2005-03-25
  • 打赏
  • 举报
回复
'我不用下面的,要用原来的文件名
filename=SavePath&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&"."&fileExt

ofile.SaveToFile Server.mappath(FileName) '保存文件
_______________________________________________________________________
没有测试过

filename = oFile.filename
  • 打赏
  • 举报
回复
http://blog.csdn.net/liuxiaoyi666/archive/2004/10/15/137477.aspx

'取得文件名
iFindStart = InStr(iFindEnd,sInfo,"filename=""",1)+10
iFindEnd = InStr(iFindStart,sInfo,"""",1)
sFileName = Mid (sinfo,iFindStart,iFindEnd-iFindStart)
theFile.FileName=getFileName(sFileName)
theFile.FilePath=getFilePath(sFileName)
rainxiang 2005-03-24
  • 打赏
  • 举报
回复
那为什么上传的时候不用它原先的文件名呢??
不懂
cheng17 2005-03-24
  • 打赏
  • 举报
回复
上传页面:
<form name="form1"><input type=text name=text1></form>

<script>//这里用来返回来到上传页面
parent.form1.text1.value=<%=uploadName%>
</script>
dadaweiwei 2005-03-24
  • 打赏
  • 举报
回复
要看你用的组件有无此方法.
  • 打赏
  • 举报
回复
你把你的无组的源码列出来
flying310 2005-03-24
  • 打赏
  • 举报
回复
getFileName
yiyioo 2005-03-24
  • 打赏
  • 举报
回复
一般来说,取得原文件名都是filaname
把filename=s。。。。
改成filename=upload.filename
试试看吧~`
如果路径不对再改路径~~~
king2003 2005-03-24
  • 打赏
  • 举报
回复
这你得看一看他的类里面有没有得到文件名的方法。如果没有只能想别的方法了
liuyingzi 2005-03-24
  • 打赏
  • 举报
回复
'我不用下面的,要用原来的文件名

'filename=SavePath&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&"."&fileExt

<%@language=vbscript codepage=936 %>
<!--#include file="Inc/config.asp"-->
<!--#include file="Inc/upfile_class.asp"-->
<%
const upload_type=0 '上传方法:0=无惧无组件上传类,1=FSO上传 2=lyfupload,3=aspupload,4=chinaaspupload

dim upload,oFile,Name,SavePath,filename,fileExt
dim ImgWidth,ImgHeight
dim EnableUpload
dim arrUpFileType
dim ranNum
dim msg,FoundErr
msg=""
FoundErr=false
EnableUpload=false
SavePath = SaveUpFilesPath '存放上传文件的目录
if right(SavePath,1)<>"/" then SavePath=SavePath&"/" '在目录后加(/)
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body leftmargin="2" topmargin="0" marginwidth="0" marginheight="0">
<%
if EnableUploadFile="No" then
response.write "系统未开放文件上传功能"
else
select case upload_type
case 0
call upload_0() '使用环境无组件上传类
case else
'response.write "本系统未开放插件功能"
'response.end
end select

end if
%>
</body>
</html>
<%
sub upload_0() '使用环境无组件上传类
set upload=new upfile_class ''建立上传对象
upload.GetData(104857600) '取得上传数据,限制最大上传100M
if upload.err > 0 then '如果出错
select case upload.err
case 1
response.write "请先选择你要上传的文件!"
case 2
response.write "你上传的文件总大小超出了最大限制(100M)"
end select
response.end
end if

ImgWidth=trim(upload.form("ImgWidth"))
ImgHeight=trim(upload.form("ImgHeight"))
if ImgWidth="" then
ImgWidth=0
else
ImgWidth=Clng(ImgWidth)
end if
if ImgHeight="" then
ImgHeight=0
else
ImgHeight=Clng(ImgHeight)
end if

for each formName in upload.file '列出所有上传了的文件
set ofile=upload.file(formName) '生成一个文件对象
if ofile.filesize<100 then
msg="请先选择你要上传的文件!"
FoundErr=True
end if
if ofile.filesize>(MaxFileSize*1024) then
msg="文件大小超过了限制,最大只能上传" & CStr(MaxFileSize) & "K的文件!"
FoundErr=true
end if

fileExt=lcase(ofile.FileExt)
arrUpFileType=split(UpFileType,"|")
for i=0 to ubound(arrUpFileType)
if fileEXT=trim(arrUpFileType(i)) then
EnableUpload=true
exit for
end if
next
if fileEXT="asp" or fileEXT="asa" or fileEXT="aspx" then
EnableUpload=false
end if
if EnableUpload=false then
msg="这种文件类型不允许上传!\n\n只允许上传这几种文件类型:" & UpFileType
FoundErr=true
end if


strJS="<SCRIPT language=javascript>" & vbcrlf
if FoundErr<>true then
randomize
ranNum=int(900*rnd)+100
'我不用下面的,要用原来的文件名
filename=SavePath&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&"."&fileExt

ofile.SaveToFile Server.mappath(FileName) '保存文件

msg="上传文件成功!"

strJS=strJS & "parent.HtmlEdit.focus();" & vbcrlf
strJS=strJS & "var range = parent.HtmlEdit.document.selection.createRange();" & vbcrlf
select case FileExt
case "jpg","gif","png","bmp"
strJS=strJS & "range.pasteHTML('<img src=" & filename
if ImgWidth>0 then
strJS=strJS & " width=" & ImgWidth
end if
if ImgHeight>0 then
strJS=strJS & " height=" & ImgHeight
end if
strJS=strJS & " border=0>');" & vbcrlf
case "swf"
strJS=strJS & "range.pasteHTML('<object classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"
if ImgWidth>0 then
strJS=strJS & " width=" & ImgWidth
end if
if ImgHeight>0 then
strJS=strJS & " height=" & ImgHeight
end if
strJS=strJS & "><param name=movie value=" & FileName & ">"
strJS=strJS & "<param name=quality value=high>"
strJS=strJS & "<embed src=" & FileName & " quality=high pluginspage=http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash type=application/x-shockwave-flash"
if ImgWidth>0 then
strJS=strJS & " width=" & ImgWidth
end if
if ImgHeight>0 then
strJS=strJS & " height=" & ImgHeight
end if
strJS=strJS & "></embed></object>');" & vbcrlf
case else
strJS=strJS & "range.text='[upload=" & FileExt & "]" & FileName & "[/upload]';" & vbcrlf
end select
strJS=strJS & "parent.myform.IncludePic1.value='" & filename & "';" & vbcrlf
end if
strJS=strJS & "alert('" & msg & "');" & vbcrlf
strJS=strJS & "history.go(-1);" & vbcrlf
strJS=strJS & "</script>"
response.write strJS
set file=nothing
next
set upload=nothing
end sub
%>
liuyingzi 2005-03-24
  • 打赏
  • 举报
回复
用的是无组件上传,上传时不改变文件名,如原来是wenjian.txt上传后还是一样的文件名
king2003 2005-03-24
  • 打赏
  • 举报
回复
你用什么东西上传的得说出来呀

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧