哪个有上传文件(JPG /GIF)到服务器目录下的组件,最好带个实例
在线等
---------------------------------------------------------------
http://xingworld.net/help/xingerup/
---------------------------------------------------------------
搜索lyfupload
---------------------------------------------------------------
1<form name="upload">
2<table border="0" cellpadding="5" cellspacing="0" class="12pxb" width="100%">
3<tr>
4<td colspan="2"><font color="#FF0000">上传提示:</font><br/>由于服务器负载过重的原因,所以上传图片需要调用客户端——也就是您——的电脑上的程序,期间会出现以下提示:<br/>
5<font color="#0000FF">Microsoft ADO/RDS提示:
6此页正在访问其他域的数据。您允许这样做吗?</font><br/>
7不必惊慌,请点“是”即可上传您的图片了!谢谢!</td>
8</tr>
9<tr>
10<td width="100">您的图片</td>
11<td><input name="pic" onchange="thisPic=document.createElement('img');thisPic.src=this.value" size="20" type="file"/></td>
12</tr>
13<tr>
14<td>给图片写个标题</td>
15<td><input name="title" size="20"/></td>
16</tr>
17<tr>
18<td valign="top">给图片加几段精彩介绍</td>
19<td><textarea cols="50" name="content" rows="10"></textarea></td>
20</tr>
21<tr>
22<td align="center" colspan="2"><input id="upbtn" type="button" value="写好了"/></td>
23</tr>
24</table>
25</form>
1<script language="JavaScript">
2var adTypeBinary = 1
3var adTypeText = 2
4var thisPic
5var stest, up
6try{
7stest = new ActiveXObject("ADODB.Stream");
8up = true
9}
10catch(e){
11up = false
12}
13function bstr(vin){
14var aStream = new ActiveXObject("adodb.stream")
15with (aStream){
16Type = adTypeText
17Open()
18WriteText(vin)
19Position = 0
20Charset = "GB2312"
21Position = 2
22var datarep = ReadText
23close()
24}
25return datarep
26}
27
28function upload.upbtn.onclick(){
29var uPic = upload.pic.value
30var uTitle = upload.title.value
31var uContent = upload.content.value
32if (validPic()!="") alert(validPic())
33else{
34if (uTitle=="" ¦ ¦uContent=="") alert("请给图片写个标题和简单介绍,谢谢!")
35else{
36
37if(!up) alert("您的浏览器版本太低,无法上传图片,请升级您的浏览器至IE5.02以上!")
38else{
39var st = new ActiveXObject("adodb.stream")
40st.Type = 1; // 1=adTypeBinary
41st.Open();
42try{
43st.LoadFromFile(uPic);
44var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
45xmldoc.loadXML('<?xml version="1.0"?><root/>');
46xmldoc.documentElement.setAttribute("xmlns:dt", "urn:schemas-microsoft-com:datatypes");
47var iTitle = xmldoc.createElement("title")
48var iContent = xmldoc.createElement("content")
49var iPic = xmldoc.createElement("pic")
50iTitle.text = uTitle
51iContent.text = uContent
52iPic.dataType = "bin.base64";
53iPic.nodeTypedValue = st.Read(-1); // -1=adReadAll
54st.Close();
55xmldoc.documentElement.appendChild(iTitle);
56xmldoc.documentElement.appendChild(iContent);
57xmldoc.documentElement.appendChild(iPic);
58var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
59xmlhttp.open("POST","upload.asp",false);
60xmlhttp.send(xmldoc);
61if(xmlhttp.readyState==4){
62var infor = bstr(xmlhttp.responseBody)
63if (infor=="success") alert("right")
64else alert(infor)
65}
66}
67catch(e){alert("无法找到文件!")}
68}
69}
70}
71}
72
73function validPic(){
74var str = ''
75if(!thisPic ¦ ¦thisPic.src=="") str = '请选择您要上传的图片'
76else{
77var picSize = thisPic.fileSize/1024
78if(picSize>50) str = '上传的图片不要大于50KB,您的图片有'+picSize+'KB'
79else{
80var sPic = thisPic.src.split(".")
81var pf = sPic[sPic.length-1].toLowerCase()
82if(pf!=("gif" ¦ ¦"jpg" ¦ ¦"jpeg")) str = '未知的图片格式!'
83}
84}
85return str
86}
87</script>
1<img border="0" src="image.asp?id=0"/>
---------------------------------------------------------------
1@ LANGUAGE=VBScript
1Option Explicit
1
2Response.Expires = 0
3dim xmldom
4dim root,title,content,pic
5dim xmldoc,xmlPath
6dim name
7dim PreURL
8dim ServerName
9name = request.cookies("name")
10PreURL = Request.ServerVariables("HTTP_REFERER")
11ServerName = Request.ServerVariables("Server_Name")
12if name="" then
13response.write "您还没有登陆"&vbnewline&"该服务只对会员开放,请您登陆后再上传图片"
14else
15xmlPath = Server.MapPath("image.xml")
16set xmldom = Server.CreateObject("Microsoft.XMLDOM")
17xmldom.async = false
18xmldom.load(request)
19set root = xmldom.selectSingleNode("root")
20title = root.childNodes(0).text
21content = root.childNodes(1).text
22set pic = root.childNodes(2)
23if samePic(pic.nodeTypedValue)=true then
24response.write "请勿上传相同的图片"&vbnewline
25else
26dim iUser,iRoot,iTitle,iContent,iPic,iLevel,iHit,iTime
27dim shows
28set xmldoc = Server.CreateObject("Microsoft.XMLDOM")
29xmldoc.async = false
30xmldoc.load xmlPath
31if xmldoc.parseError.errorCode<>0 then
32dim xmlhead,xslhead
33set xmlhead = xmldoc.createProcessingInstruction("xml","version=""1.0"" encoding=""GB2312""")
34'set xslhead = xmldoc.createProcessingInstruction("xml-stylesheet","type=""text/xsl"" href=""image.xsl""")
35xmldoc.insertBefore xmlhead,xmldoc.childNodes(0)
36'xmldoc.insertBefore xslhead,xmldoc.childNodes(1)
37set iRoot = xmldoc.createElement("root")
38xmldoc.appendChild iRoot
39else
40set iRoot = xmldoc.documentElement
41end if
42set shows = xmldoc.createElement("show")
43set iUser = xmldoc.createElement("user")
44set iTitle = xmldoc.CreateElement("title")
45set iContent = xmldoc.createElement("content")
46set iPic = xmldoc.createElement("pic")
47set iLevel = xmldoc.createElement("level")
48set iHit = xmldoc.createElement("hit")
49set iTime = xmldoc.createElement("time")
50iUser.text = name
51iTitle.text = title
52iContent.text = content
53iPic.dataType="bin.base64"
54iPic.nodeTypedValue = pic.nodeTypedValue
55iLevel.text = "up"
56iHit.text = 0
57iTime.text = now()
58iRoot.appendChild shows
59shows.appendChild iUser
60shows.appendChild iTitle
61shows.appendChild iContent
62shows.appendChild iPic
63shows.appendChild iLevel
64shows.appendChild iHit
65shows.appendChild iTime
66xmldoc.Save xmlPath
67set xmldom = Nothing
68set xmldoc = Nothing
69Response.Write "success"
70end if
71end if
---------------------------------------------------------------
1
2function samePic(str)
3dim xmldoc
4dim a,i,pic
5samePic = false
6set xmldoc = Server.CreateObject("Microsoft.XMLDOM")
7xmldoc.async = false
8xmldoc.load Server.MapPath("image.xml")
9if xmldoc.parseError.errorCode<>0 then
10samePic = false
11else
12set a = xmldoc.selectNodes("/*/*")
13for i=0 to a.length-1
14if len(str)=len(a(i).selectSingleNode("pic").nodeTypedValue) then
15samePic = true
16exit for
17end if
18next
19end if
20end function