?? post_upload.asp
字號(hào):
<!-- #include File="inc/Upload_Class.asp" -->
<%
If Request("t")="1" Then
Upfile_Main()
Else
Main()
End If
Sub Main()
%>
<style>
BODY{
font-family:verdana,arial,helvetica;
margin:0;
}
td {
font-family:Tahoma,Verdana, Arial;
font-size:11px;
}
A:link, A:active,A:visited
{
color: #CCCCCC;
text-decoration: none;
padding-left:6px;
padding-right:6px;
}
A:hover
{
color: #FF3300;
text-decoration: none;
padding-left:6px;
padding-right:6px;
}
</style><table width="51%" border=0 cellpadding=0 cellspacing=0 >
<form name="form" method="post" action="post_upload.asp?t=1" enctype="multipart/form-data">
<tr>
<%
Dim PostRanNum
Randomize
PostRanNum = Int(900*rnd)+1000
Session("UploadCode") = Cstr(PostRanNum)
%>
<INPUT TYPE="hidden" NAME="UploadCode" value="<%=PostRanNum%>">
<TD valign=top class=tablebody2 id="upid"><input type="file" name="file1" width=200 value="" size="20" />
<input type="submit" name="Submit" value="上傳"></TD>
</tr>
</form>
</table>
<p>注:支持上傳圖片格式:.gif .jpeg .jpg .bmp .png </p>
<%
End Sub
Sub Upfile_Main()
'-----------------------------------------------------------------------------
'提交驗(yàn)證
'-----------------------------------------------------------------------------
UploadFile
%>
<%
End Sub
Sub UploadFile()
Dim Upload,FormName,FilePath,ChildFilePath
Dim File,F_FileName,F_ViewName,F_Filesize,F_FileExt,F_Type
'上傳目錄
FilePath = CreatePath(CheckFolder)
Set Upload = New UpFile_Cls
Upload.UploadType = 0 '設(shè)置上傳組件類型
Upload.UploadPath = FilePath '設(shè)置上傳路徑
Upload.InceptFileType = "gif,jpeg,jpg,bmp,doc,rar,zip" '設(shè)置上傳文件限制
Upload.MaxSize = 20000000 '單位 KB
Upload.InceptMaxFile = 1 '每次上傳文件個(gè)數(shù)上限
Upload.ChkSessionName = "UploadCode" '防止重復(fù)提交,SESSION名與提交的表單要一致。
'執(zhí)行上傳
Upload.SaveUpFile
If Upload.ErrCodes<>0 Then
Response.write "錯(cuò)誤:"& Upload.Description & "[ <a href=""post_upload.asp?"">重新上傳</a> ]"
Exit Sub
End If
If Upload.Count > 0 Then
For Each FormName In Upload.UploadFiles
Set File = Upload.UploadFiles(FormName)
F_FileName = FilePath & File.FileName
Response.write "<script>window.opener.document.form1.bookpic.value='"&F_FileName&"'</script>"
Response.write "<script language=javascript>"
Response.write "alert('文件上傳成功!請(qǐng)不要修改生成的地址!');"
Response.write "window.close();"
response.write "</script>"
Set File = Nothing
Next
Else
Response.write "請(qǐng)正確選擇要上傳的文件。[ <a href=""post_upload.asp"">重新上傳</a> ]"
Exit Sub
End If
Set Upload = Nothing
End Sub
'讀取上傳目錄
Function CheckFolder()
CheckFolder = Replace(Replace("UploadFile/",Chr(0),""),".","")
'在目錄后加(/)
If Right(CheckFolder,1)<>"/" Then CheckFolder=CheckFolder&"/"
End Function
'按月份自動(dòng)明名上傳文件夾,需要FSO組件支持。
Private Function CreatePath(PathValue)
Dim objFSO,Fsofolder,uploadpath
'以年月創(chuàng)建上傳文件夾,格式: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
%>
</p>
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -