我想通过账号验证后,能通过IE把文件传到我的空间里
就像yahoo中国站,曾经的网易,chinaren,好像都提供过简易上传
PS:我的空间是买的
---------------------------------------------------------------
是WEB上传吧?你参考下面的网页:
http://www.5xsoft.com/data/200108/3108123101.htm
http://www.4gee.com/colleges/programme/017.htm
现成的程序:
http://down.89dns.net/download.asp?downid=1&id=1863
http://down.89dns.net/download.asp?downid=1&id=1726
估计你和我一样不是高手,建议你学习一门动态网页编程技术吧。
我正在学ASP。
---------------------------------------------------------------
给你个例子参考一下:
正无组件图文混合上传,功能强大,无须数据库,支持中文!
受本论坛某些帖子启发,于是动手编写了这个程序。该程序支持任何文本和二进制格式文件的上传;支持文件表单域和普通表单域混合上传;支持中文文件名;支持覆盖上传和文件同名时自动修改文件名;支持同时上传多个文件,而且多个文件表单域名可以相同;支持上传文件大小的控制…… 我自己感觉很不错哟:)
本程序无须任何数据库支持,直接将上传的文件保存到服务器指定的路径下。
测试环境:Windows2000 + IIS 5.0(对ADO版本有要求)
已知BUG:利用相同文件表单名以唯一文件名方式同时上传多个文件,且服务器上存在多个相同文件名时,只有第一个文件会自动改名上传成功,然后程序报错。
源代码如下,欢迎大家参考指正:
文件名:UploadX.asp
1
2Dim FormData, FormSize, Divider, bCrLf
3FormSize = Request.TotalBytes
4FormData = Request.BinaryRead(FormSize)
5bCrLf = ChrB(13) & ChrB(10)
6Divider = LeftB(FormData, InStrB(FormData, bCrLf) - 1)
7
8'将上传的文件保存到path所指定的目录下面。
9'Formfield 上传表单的"file"域名
10'Path 要保存文件的服务器绝对路径,形式为:"d:\path\subpath"或"d:\path\subpath\"
11'MaxSize 限制上传文件的最大长度,以KByte为单位
12'SavType 服务器保存文件的方式:
13' 0 唯一文件名方式,如果有同名则自动改名;
14' 1 报错方式,如果有同名则出错;
15' 2 覆盖方式,如果有同名则覆盖原来的文件
16Function SaveFile(FormFileField, Path, MaxSize, SavType)
17Dim StreamObj,StreamObj1
18Set StreamObj = Server.CreateObject("ADODB.Stream")
19Set StreamObj1 = Server.CreateObject("ADODB.Stream")
20StreamObj.Mode = 3
21StreamObj1.Mode = 3
22StreamObj.Type = 1
23StreamObj1.Type = 1
24SaveFile = ""
25StartPos = LenB(Divider) + 2
26FormFileField = Chr(34) & FormFileField & Chr(34)
27If Right(Path,1) <> "\" Then
28Path = Path & "\"
29End If
30Do While StartPos > 0
31strlen = InStrB(StartPos, FormData, bCrLf) - StartPos
32SearchStr = MidB(FormData, StartPos, strlen)
33If InStr(bin2str(SearchStr), FormFileField) > 0 Then
34FileName = bin2str(GetFileName(SearchStr,path,SavType))
35If FileName <> "" Then
36FileStart = InStrB(StartPos, FormData, bCrLf & bCrLf) + 4
37FileLen = InStrB(StartPos, FormData, Divider) - 2 - FileStart
38If FileLen <= MaxSize*1024 Then
39FileContent = MidB(FormData, FileStart, FileLen)
40StreamObj.Open
41StreamObj1.Open
42StreamObj.Write FormData
43StreamObj.Position=FileStart-1
44StreamObj.CopyTo StreamObj1,FileLen
45If SavType =0 Then
46SavType = 1
47End If
48StreamObj1.SaveToFile Path & FileName, SavType
49StreamObj.Close
50StreamObj1.Close
51If SaveFile <> "" Then
52SaveFile = SaveFile & "," & FileName
53Else
54SaveFile = FileName
55End If
56Else
57If SaveFile <> "" Then
58SaveFile = SaveFile & ",*TooBig*"
59Else
60SaveFile = "*TooBig*"
61End If
62End If
63End If
64End If
65If InStrB(StartPos, FormData, Divider) < 1 Then
66Exit Do
67End If
68StartPos = InStrB(StartPos, FormData, Divider) + LenB(Divider) + 2
69Loop
70End Function
71
72Function GetFormVal(FormName)
73GetFormVal = ""
74StartPos = LenB(Divider) + 2
75FormName = Chr(34) & FormName & Chr(34)
76Do While StartPos > 0
77strlen = InStrB(StartPos, FormData, bCrLf) - StartPos
78SearchStr = MidB(FormData, StartPos, strlen)
79If InStr(bin2str(SearchStr), FormName) > 0 Then
80ValStart = InStrB(StartPos, FormData, bCrLf & bCrLf) + 4
81ValLen = InStrB(StartPos, FormData, Divider) - 2 - ValStart
82ValContent = MidB(FormData, ValStart, ValLen)
83If GetFormVal <> "" Then
84GetFormVal = GetFormVal & "," & bin2str(ValContent)
85Else
86GetFormVal = bin2str(ValContent)
87End If
88End If
89If InStrB(StartPos, FormData, Divider) < 1 Then
90Exit Do
91End If
92StartPos = InStrB(StartPos, FormData, Divider) + LenB(Divider) + 2
93Loop
94End Function
95
96Function bin2str(binstr)
97Dim varlen, clow, ccc, skipflag
98skipflag = 0
99ccc = ""
100varlen = LenB(binstr)
101For i = 1 To varlen
102If skipflag = 0 Then
103clow = MidB(binstr, i, 1)
104If AscB(clow) > 127 Then
105ccc = ccc & Chr(AscW(MidB(binstr, i + 1, 1) & clow))
106skipflag = 1
107Else
108ccc = ccc & Chr(AscB(clow))
109End If
110Else
111skipflag = 0
112End If
113Next
114bin2str = ccc
115End Function
116
117Function str2bin(str)
118For i = 1 To Len(str)
119str2bin = str2bin & ChrB(Asc(Mid(str, i, 1)))
120Next
121End Function
122
123Function GetFileName(str,path,savtype)
124Set fs = Server.CreateObject("Scripting.FileSystemObject")
125str = RightB(str,LenB(str)-InstrB(str,str2bin("filename="))-9)
126GetFileName = ""
127FileName = ""
128For i = LenB(str) To 1 Step -1
129If MidB(str, i, 1) = ChrB(Asc("\")) Then
130FileName = MidB(str, i + 1, LenB(str) - i - 1)
131Exit For
132End If
133Next
134If savtype = 0 and fs.FileExists(path & bin2str(FileName)) = True Then
135hFileName = FileName
136rFileName = ""
137For i = LenB(FileName) To 1 Step -1
138If MidB(FileName, i, 1) = ChrB(Asc(".")) Then
139hFileName = LeftB(FileName, i-1)
140rFileName = RightB(FileName, LenB(FileName)-i+1)
141Exit For
142End If
143Next
144For i = 0 to 9999
145'hFileName = hFileName & str2bin(i)
146If fs.FileExists(path & bin2str(hFileName) & i & bin2str(rFileName)) = False Then
147FileName = hFileName & str2bin(i) & rFileName
148Exit For
149End If
150Next
151End If
152Set fs = Nothing
153GetFileName = FileName
154End Function
应用举例:
upload.htm
1<html>
2<head>
3<meta content="zh-cn" http-equiv="Content-Language"/>
4<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
5<meta content="Microsoft FrontPage 4.0" name="GENERATOR"/>
6<meta content="FrontPage.Editor.Document" name="ProgId"/>
7<title>New Page 1</title>
8</head>
9<body>
10<form action="upload.asp" enctype="multipart/form-data" method="POST">
11<p>姓名:<input name="name" size="20" type="text"/></p>
12<p>城市:<input name="city" size="20" type="text"/></p>
13<p>爱好:1、<input name="lover" size="10" type="text"/> 2、<input name="lover" size="10" type="text"/></p>
14<p>性别:<input checked="" name="sex" type="radio" value="男"/>男
15<input name="sex" type="radio" value="女"/>女</p>
16<p>省份:<select name="province" size="1">
17<option selected="" value="江苏">江苏</option>
18<option value="山西">山西</option>
19</select></p>
20爱好(补充):3、<input name="lover" size="10" type="text"/> 4、<input name="lover" size="10" type="text"/>
21<p>作品1:<input name="fruit" size="20" type="file"/></p>
22<p>作品1:<input name="fruit" size="20" type="file"/></p>
23<p>作品2:<input name="fruit2" size="20" type="file"/></p>
24<p><input name="subbutt" type="submit" value="提交"/><input name="rebutt" type="reset" value="全部重写"/></p>
25</form>
26</body>
27</html>
upload.asp
1@ LANGUAGE = VBScript
1
2Response.Write "
3Name=""" & GetFormVal("name") & """"
4Response.Write "
5Sex=""" & GetFormVal("sex") & """"
6Response.Write "
7province=""" & GetFormVal("province") & """"
8Response.Write "
9city=""" & GetFormVal("city") & """"
10Response.Write "
11lover=""" & GetFormVal("lover") & """"
12dim filename
13path = Server.MapPath("./")
14filename = SaveFile("fruit",path,1024,0)
15If filename <> "*TooBig*" Then
16Response.Write "
17
18""" & filename & """已经上传"
19Else
20Response.Write "
21
22文件超出限制太大"
23End IF
24
25filename = SaveFile("fruit2",path,1024,0)
26If filename <> "*TooBig*" Then
27Response.Write "
28
29""" & filename & """已经上传"
30Else
31Response.Write "
32
33文件超出限制太大"
34End IF
---------------------------------------------------------------
thank u