⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 upload.asp

📁 就是这样的一个源码
💻 ASP
字号:
<!--#include FILE="inc/upload_5xsoft.inc"-->
<!--#include file="top.asp"-->
<!--#include file="chk.asp"-->
<%
action=request("action")
select CASE action
  case "save"
    call save()
  case else
    call main()
END select

sub main()
%>
<table cellpadding="0" cellspacing="0">
<form name="form1" method="post" action="upload.asp?action=save" enctype="multipart/form-data">
       <tr><td><input type="file" name="file" style="width:200" class="tx1" value="">
        </td><td><input type="submit" name="Submit" value="上传文件" class="bt"></td></tr>
</form>
</table>
<%
end sub

sub save()

dim maxsize
 maxsize=307200  ''''''''文件大小限制,可自行修改

dim upload,file,formName,formPath,fname,ranNum,fileExt,CheckFiletype
set upload=new upload_5xSoft ''建立上传对象

formPath="/upload/"
formPath=CreatePath(formPath)
for each formName in upload.file ''列出所有上传了的文件
 set file=upload.file(formName)  ''生成一个文件对象

fname=file.FileName
 fileExt=lcase(right(fname,4))   
 fileExt= replace(fileExt, ".", "")

   randomize    
           ranNum=int(90000*rnd)+10000  
    fname=hour(now()) & minute(now()) & second(now()) & ranNum
      '生成一段随机数附加到文件末尾,以防止文件名冲突
    fname=fname&"."&fileExt

if file.FileSize>maxsize then
  Response.Write "文件大小超过限制[ <a href=# onclick=history.go(-1)>重新上传</a> ]"
  response.end
  end if

Select Case fileExt
	Case "gif", "jpg", "jpeg","swf"
                    ''''''''''''''''''''''''''在此修改允许上传的文件扩展名
		CheckFiletype=1
	Case Else
		CheckFiletype=0
End Select

if CheckFiletype=0 then 
  Response.Write("<a href='javascript:history.go(-1);'>文件格式非法 [返回]</a>")
  response.end
  end if

if file.FileSize>0 then
  file.SaveAs Server.mappath(formPath&fname)   ''保存文件
  response.write ("<SCRIPT>parent.input.content.value+='\n[img]"&formPath&""&fname&"[/img]'</SCRIPT>")
	Response.Write("<SCRIPT>parent.input.content.focus()</SCRIPT>上传成功!<a href='javascript:history.go(-1);'> [继续上传]</a>")
 end if
 set file=nothing
next
set upload=nothing  ''删除此对象
end sub

Private Function CreatePath(PathValue)
	Dim objFSO,Fsofolder,uploadpath
	'以年月创建上传文件夹,格式:2003-8
	uploadpath = year(now) & "-" & month(now)
	If Right(PathValue,1)<>"/" Then PathValue = PathValue&"/"
	On Error Resume Next
	Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
		If objFSO.FolderExists(Server.MapPath(PathValue & uploadpath))=False Then
			objFSO.CreateFolder Server.MapPath(PathValue & uploadpath)
		End If
		If Err.Number = 0 Then
			CreatePath = PathValue & uploadpath & "/"
		Else
			CreatePath = PathValue
		End If
	Set objFSO = Nothing
End Function
%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -