ÏúÊÛÈÈÏß:027-84490075    15071122275 ¿Í»§Ö§³Ö - ½»·Ñ·½Ê½ - ÁªÏµÎÒÃÇ - ¼ÓÈëÊÕ²Ø - ·±ów

ÐéÄâÖ÷»úAspÎÞ×é¼þÎļþÉÏ´«µ½×âÓ÷þÎñÆ÷¿Õ¼äµÄʵÀý

·¢²¼Ê±¼ä:2006-06-18 22:09:24   ä¯ÀÀÈËÊý: 579590 ´Î  
  ¹Ø¼ü×Ö: ÎÞ×é¼þÉÏ´« - ±¾Õ¾ËÑË÷ - GoogleËÑË÷ - BaiduËÑË÷ - YahooËÑË÷ - sougoËÑË÷
  ¹Ø¼ü×Ö: AspÎÞ×é¼þÉÏ´« - ±¾Õ¾ËÑË÷ - GoogleËÑË÷ - BaiduËÑË÷ - YahooËÑË÷ - sougoËÑË÷

1.¿âÎļþ(upload.inc.asp)
<%
Dim oUpFileStream

Class UpFile_Class

Dim Form,File,Version,Err

Private Sub Class_Initialize
Version = "ÎÞ×é¼þÉÏ´«Àà Version V1.0"
Err = -1
End Sub

Private Sub Class_Terminate
'Çå³ý±äÁ¿¼°¶ÔÏñ
If Err < 0 Then
Form.RemoveAll
Set Form = Nothing
File.RemoveAll
Set File = Nothing
oUpFileStream.Close
Set oUpFileStream = Nothing
End If
End Sub

Public Sub GetData (RetSize)
'¶¨Òå±äÁ¿
Dim RequestBinDate,sSpace,bCrLf,sInfo,iInfoStart,iInfoEnd,tStream,iStart,oFileInfo
Dim iFileSize,sFilePath,sFileType,sFormValue,sFileName
Dim iFindStart,iFindEnd
Dim iFormStart,iFormEnd,sFormName
'´úÂ뿪ʼ
If Request.TotalBytes < 1 Then
Err = 1
Exit Sub
End If
If RetSize > 0 Then
If Request.TotalBytes > RetSize Then
Err = 2
Exit Sub
End If
End If
Set Form = Server.CreateObject ("Scripting.Dictionary")
Form.CompareMode = 1
Set File = Server.CreateObject ("Scripting.Dictionary")
File.CompareMode = 1
Set tStream = Server.CreateObject ("ADODB.Stream")
Set oUpFileStream = Server.CreateObject ("ADODB.Stream")
oUpFileStream.Type = 1
oUpFileStream.Mode = 3
oUpFileStream.Open
oUpFileStream.Write Request.BinaryRead (Request.TotalBytes)
oUpFileStream.Position = 0
RequestBinDate = oUpFileStream.Read
iFormEnd = oUpFileStream.Size
bCrLf = ChrB (13) & ChrB (10)
'È¡µÃÿ¸öÏîÄ¿Ö®¼äµÄ·Ö¸ô·û
sSpace = MidB (RequestBinDate,1, InStrB (1,RequestBinDate,bCrLf)-1)
iStart = LenB (sSpace)
iFormStart = iStart+2
'·Ö½âÏîÄ¿
Do
iInfoEnd = InStrB (iFormStart,RequestBinDate,bCrLf & bCrLf)+3
tStream.Type = 1
tStream.Mode = 3
tStream.Open
oUpFileStream.Position = iFormStart
oUpFileStream.CopyTo tStream,iInfoEnd-iFormStart
tStream.Position = 0
tStream.Type = 2
tStream.CharSet = "gb2312"
sInfo = tStream.ReadText
'È¡µÃ±íµ¥ÏîÄ¿Ãû³Æ
iFormStart = InStrB (iInfoEnd,RequestBinDate,sSpace)-1
iFindStart = InStr (22,sInfo,"name=""",1)+6
iFindEnd = InStr (iFindStart,sInfo,"""",1)
sFormName = Mid (sinfo,iFindStart,iFindEnd-iFindStart)
'Èç¹ûÊÇÎļþ
If InStr (45,sInfo,"filename=""",1) > 0 Then
Set oFileInfo = new FileInfo_Class
'È¡µÃÎļþÊôÐÔ
iFindStart = InStr (iFindEnd,sInfo,"filename=""",1)+10
iFindEnd = InStr (iFindStart,sInfo,"""",1)
sFileName = Mid (sinfo,iFindStart,iFindEnd-iFindStart)
oFileInfo.FileName = Mid (sFileName,InStrRev (sFileName, "")+1)
oFileInfo.FilePath = Left (sFileName,InStrRev (sFileName, "")+1)
oFileInfo.FileExt = Mid (sFileName,InStrRev (sFileName, ".")+1)
iFindStart = InStr (iFindEnd,sInfo,"Content-Type: ",1)+14
iFindEnd = InStr (iFindStart,sInfo,vbCr)
oFileInfo.FileType = Mid (sinfo,iFindStart,iFindEnd-iFindStart)
oFileInfo.FileStart = iInfoEnd
oFileInfo.FileSize = iFormStart -iInfoEnd -2
oFileInfo.FormName = sFormName
file.add sFormName,oFileInfo
else
'Èç¹ûÊÇ±íµ¥ÏîÄ¿
tStream.Close
tStream.Type = 1
tStream.Mode = 3
tStream.Open
oUpFileStream.Position = iInfoEnd
oUpFileStream.CopyTo tStream,iFormStart-iInfoEnd-2
tStream.Position = 0
tStream.Type = 2
tStream.CharSet = "gb2312"
sFormValue = tStream.ReadText
If Form.Exists (sFormName) Then
Form (sFormName) = Form (sFormName) & ", " & sFormValue
else
form.Add sFormName,sFormValue
End If
End If
tStream.Close
iFormStart = iFormStart+iStart+2
'Èç¹ûµ½ÎļþβÁ˾ÍÍ˳ö
Loop Until (iFormStart+2) = iFormEnd
RequestBinDate = ""
Set tStream = Nothing
End Sub
End Class

'ÎļþÊôÐÔÀà
Class FileInfo_Class
Dim FormName,FileName,FilePath,FileSize,FileType,FileStart,FileExt
'±£´æÎļþ·½·¨
Public Function SaveToFile (Path)
On Error Resume Next
Dim oFileStream
Set oFileStream = CreateObject ("ADODB.Stream")
oFileStream.Type = 1
oFileStream.Mode = 3
oFileStream.Open
oUpFileStream.Position = FileStart
oUpFileStream.CopyTo oFileStream,FileSize
oFileStream.SaveToFile Path,2
oFileStream.Close
Set oFileStream = Nothing
if Err.Number<>0 then
SaveToFile=err.number&"**"&Err.descripton
else
SaveToFile="ok"
end if
End Function

'È¡µÃÎļþÊý¾Ý
Public Function FileDate
oUpFileStream.Position = FileStart
FileDate = oUpFileStream.Read (FileSize)
End Function
End Class
%>


2.´¦ÀíÓû§Ìá½»ºóµÄÒ³Ãæ(upload.asp)
<!--#include file="upload.inc.asp"-->
<html>
<head>
<title>ÎļþÉÏ´«</title>
</head>
<body topmargin="0" leftmargin="0">
<table width=100% border=0 cellspacing="0" cellpadding="0"><tr><td class=tablebody1 width=100% height=100% >
<%
dim upload,file,formName,formPath,filename,fileExt
dim ranNum
call UpFile()
'===========ÎÞ×é¼þÉÏ´«(upload_0)====================
sub UpFile()
set upload=new UpFile_Class '½¨Á¢ÉÏ´«¶ÔÏó
upload.GetData (500*1024) 'È¡µÃÉÏ´«Êý¾Ý,´Ë´¦¼´Îª500 K

if upload.err > 0 then
select case upload.err
case 1
Response.Write "ÇëÏÈÑ¡ÔñÄãÒªÉÏ´«µÄÎļþ¡¡[ <a href=# onclick=history.go(-1)>ÖØÐÂÉÏ´«</a> ]"
case 2
Response.Write "ͼƬ´óС³¬¹ýÁËÏÞÖÆ 500 K¡¡[ <a href=# onclick=history.go(-1)>ÖØÐÂÉÏ´«</a> ]"
end select
exit sub
else
formPath=upload.form("filepath") 'Îļþ±£´æĿ¼,´ËĿ¼±ØÐëΪ³ÌÐò¿É¶Áд
if formPath="" then
formPath="rwdata/"
end if
'ÔÚĿ¼ºó¼Ó(/)
if right(formPath,1)<>"/" then
formPath=formPath&"/"
end if

for each formName in upload.file 'ÁгöËùÓÐÉÏ´«Á˵ÄÎļþ
set file=upload.file(formName) 'Éú³ÉÒ»¸öÎļþ¶ÔÏó
if file.filesize<100 then
response.write "ÇëÏÈÑ¡ÔñÄãÒªÉÏ´«µÄͼƬ¡¡[ <a href=# onclick=history.go(-1)>ÖØÐÂÉÏ´«</a> ]"
response.end
end if

fileExt=lcase(file.FileExt)
if CheckFileExt(fileEXT)=false then
response.write "Îļþ¸ñʽ²»ÕýÈ·¡¡[ <a href=# onclick=history.go(-1)>ÖØÐÂÉÏ´«</a> ]"
response.end
end if

'randomize
ranNum=int(90000*rnd)+10000
filename=formPath&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&"."&fileExt
if file.FileSize>0 then 'Èç¹û FileSize > 0 ˵Ã÷ÓÐÎļþÊý¾Ý
result=file.SaveToFile(Server.mappath(filename)) '±£´æÎļþ
if result="ok" then
response.write formName&" upload OK, had saved to "&filename&"<br>"
else
response.write formName&" upload Fail,"&result&"<br>"
end if
end if
set file=nothing
next
set upload=nothing
end if
end sub

'ÅжÏÎļþÀàÐÍÊÇ·ñºÏ¸ñ
Private Function CheckFileExt (fileEXT)
dim Forumupload
Forumupload="gif,jpg,bmp,jpeg"
Forumupload=split(Forumupload,",")
for i=0 to ubound(Forumupload)
if lcase(fileEXT)=lcase(trim(Forumupload(i))) then
CheckFileExt=true
exit Function
else
CheckFileExt=false
end if
next
End Function
%>
</td></tr></table>
</body>
</html>



3.HTML ±íµ¥(upload.html)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>asp ÎÞ×é¼þÉÏ´«</title>
</head>

<body>
ÇëÑ¡ÔñÒªÉÏ´«µÄÎļþ
<form action="upfile.asp" method="post" enctype="multipart/form-data" name="form1">
<input type="file" name="file">
<!--<br>
<input type="file" name="file">
<br>
<input type="file" name="file">
<br>-->
<input type="submit" name="Submit" value="Ìá½»">
</form>
</body>
</html>




ÉÏһƪ£ºPHPÖ÷»ú×âÓà PHP·¢ÓʼþµÄÀý³Ì
ÏÂһƪ£ºASP.netÐéÄâÖ÷»ú Á¬½ÓaccessÊý¾Ý¿âÀý³Ì
2003-2014 °æȨËùÓРÎ人Íø¸£»¥Áª¿Æ¼¼ÓÐÏÞ¹«Ë¾   net3000.net  
ÒµÎñµç»°£º15927160396  ¿Í·þÈÈÏߣº027-84490075  ¼¼ÊõQQ£º»¶Ó­ÒµÎñ×Éѯ  ¿Í·þQQ£ºÎ人Íø¸£¿Í·þ µçÓÊ£º23444550@qq.com
ÒµÎñ²¿£ºÎ人Êй㲺ÍÍ»ªÖеç×ӳǺóÒ»¶°1µ¥Ôª201ÊÒ  ¿ª·¢²¿£ºÎ人ÄϺþ´óµÀ±£ÀûÐÄÓï25¶°1µ¥Ôª1001ÊÒ     ¶õICP±¸09022096ºÅ    
ÒÔÏÂjsΪ²âÊÔÐÅÏ¢