| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 670 人关注过本帖
标题:求大哥们帮忙!!
只看楼主 加入收藏
东邪西毒
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2005-10-28
收藏
 问题点数:0 回复次数:4 
求大哥们帮忙!!

<!--#include file="conn.asp" --> <!--#include file="upload.inc"--> <% const upload_type=0 '上传方法:0=无组件上传类 Const MaxFileSize=2000 '上传文件大小限制 Const UpFileType="png|gif|jpg|bmp" '允许的上传文件类型 dim upload,file,formName,SavePath,filename,fileExt dim upNum dim EnableUpload dim Forumupload dim ranNum dim uploadfiletype dim msg,founderr msg="" founderr=false EnableUpload=false SavePath = "UploadFile" '存放上传文件的目录 if right(SavePath,1)<>"/" then SavePath=SavePath&"/" '在目录后加(/) %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> </head> <body> <% select case upload_type case 0 call upload_0() '使用化境无组件上传类 case else 'response.write "本系统未开放插件功能" 'response.end end select %> </body> </html> <% sub upload_0() '使用化境无组件上传类 set upload=new upload_file '建立上传对象 for each formName in upload.file '列出所有上传了的文件 set file=upload.file(formName) '生成一个文件对象 if file.filesize<100 then msg="请先选择你要上传的文件!" founderr=true end if if file.filesize>(MaxFileSize*1024) then msg="文件大小超过了限制,最大只能上传" & CStr(MaxFileSize) & "K的文件!" founderr=true end if

fileExt=lcase(file.FileExt) Forumupload=split(UpFileType,"|") for i=0 to ubound(Forumupload) if fileEXT=trim(Forumupload(i)) then EnableUpload=true exit for end if next if fileEXT="asp" or fileEXT="asa" or fileEXT="aspx" then EnableUpload=false end if if EnableUpload=false then msg="这种文件类型不允许上传!\n\n只允许上传这几种文件类型:" & UpFileType founderr=true end if strJS="<SCRIPT language=javascript>" & vbcrlf if founderr<>true then randomize ranNum=int(900*rnd)+100 filename=SavePath&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&"."&fileExt file.SaveToFile Server.mappath(FileName) '保存文件 filename1=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&"."&fileExt ' set rs=server.createobject("adodb.recordset") ' sql="select * from uploadpic" ' rs.open sql,dataconn,1,3 'rs.addnew 'rs("picname")=filename1 'username=session("usersessionname") 'rs("username")=username 'rs.update 'rs.close 'set rs=nothing 'dataconn.close 'set dataconn=nothing msg="上传文件成功!" strJS=strJS & "content=parent.document.pic.a.value;" FileType=right(fileExt,3) select case FileType case "jpg","gif","png","bmp" strJS=strJS &"content=content+'" & filename & "';" & vbcrlf case "mht" strJS=strJS & "content=content+'" & filename & "';" & vbcrlf case "swf" strJS=strJS & "content=content+'" & filename & "';" & vbcrlf end select strJS=strJS & "parent.document.pic.a.value=content;" & vbcrlf strJS=strJS & "content=parent.document.pic.f.value;" FileType=right(fileExt,3) select case FileType case "jpg","gif","png","bmp" strJS=strJS &"content=content+'" & filename1 & "';" & vbcrlf case "mht" strJS=strJS & "content=content+'" & filename1 & "';" & vbcrlf case "swf" strJS=strJS & "content=content+'" & filename1 & "';" & vbcrlf end select strJS=strJS & "parent.document.pic.f.value=content;" & vbcrlf end if strJS=strJS & "alert('" & msg & "');" & vbcrlf strJS=strJS & "window.location = 'UPFX.htm';" & vbcrlf strJS=strJS & "</script>" response.write strJS set file=nothing next set upload=nothing end sub %>

----------------------------------------------------------------------------------------------------------------------

以上上传代码如何指顶 (SavePath = "UploadFile" '存放上传文件的目录)的上传目录加( ../)

小弟在此谢过

搜索更多相关主题的帖子: dim SavePath msg file 
2005-10-28 02:03
downdown
Rank: 1
等 级:新手上路
帖 子:139
专家分:0
注 册:2005-6-20
收藏
得分:0 
直接加呗!
SavePath = "../UploadFile"   '存放上传文件的目录
在相应的目录下自建一个子uploadfile文件夹
2005-10-28 08:14
东邪西毒
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2005-10-28
收藏
得分:0 
不行   "../UploadFile"   的话上传服务数据库出错
2005-10-28 17:01
islet
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:89
帖 子:6548
专家分:0
注 册:2005-1-28
收藏
得分:0 
上传文件根数据库没有直接联系吧
2005-10-28 17:03
东邪西毒
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2005-10-28
收藏
得分:0 

如果跟数据库有联系问什么本地测试可以上传主机就不行??郁闷阿

2005-10-28 17:46
快速回复:求大哥们帮忙!!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019402 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved