asp怎样上传文件到指定的文件夹,并在access中记录路径.doc_第1页
asp怎样上传文件到指定的文件夹,并在access中记录路径.doc_第2页
asp怎样上传文件到指定的文件夹,并在access中记录路径.doc_第3页
asp怎样上传文件到指定的文件夹,并在access中记录路径.doc_第4页
asp怎样上传文件到指定的文件夹,并在access中记录路径.doc_第5页
已阅读5页,还剩5页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

asp怎样上传文件到指定的文件夹,并在access中记录路径想上传文件到指定的文件夹,并在access中记录路径,在asp页面中显示所上传的软件,点击直接下载功能。注意:是上传文件,不是图片。文件包括exe、rar、zip、doc、jpg等等。 最佳答案上传文件页 index.asp 开始-index.asp 代码如下function a(htmlurl) var win = window.open(htmlurl,newwin,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=300,height=10,left=380,top=380); 汽车照片: input type=text name=qczp class=zc_input maxlength=100 value= readonly 上传文件页 index.asp 结束-uploadprod.asp 选择图片上传 开始-uploadprod.asp 代码如下上传图片function check() var mf=document.up; if (mf.image.value.length4) alert(请选择需要上传的图片.); mf.image.focus(); return false; return true; if (window.Event) document.captureEvents(Event.MOUSEUP); function nocontextmenu() event.cancelBubble = true event.returnValue = false; return false; function norightclick(e) if (window.Event) if (e.which = 2 | e.which = 3) return false; else if (event.button = 2 | event.button = 3) event.cancelBubble = true event.returnValue = false; return false; document.oncontextmenu = nocontextmenu; / for IE5+ document.onmousedown = norightclick; / for all others 上传图片 选择图片: 上传文件页 uploadprod.asp 结束-判断文件以及文件是否存在则上传 uploadprod2.asp 开始-uploadprod2.asp 源代码图片上传 if (window.Event) document.captureEvents(Event.MOUSEUP); function nocontextmenu() event.cancelBubble = true event.returnValue = false; return false; function norightclick(e) if (window.Event) if (e.which = 2 | e.which = 3) return false; else if (event.button = 2 | event.button = 3) event.cancelBubble = true event.returnValue = false; return false; document.oncontextmenu = nocontextmenu; / for IE5+ document.onmousedown = norightclick; / for all others 0 then如果 FileSize 0 说明有文件数据 FileExtName=mid (file1.FileName,InStrRev (file1.FileName, .)+1) if CheckFileType(AllowFileExtStr,FileExtName) = False then response.Write file1.FileName & 文件:不允许上传!上传文件类型有: & AllowFileExtStr & response.Write response.Write 你的IP:&Replace(Request.ServerVariables(REMOTE_ADDR),)& response.Write response.write 你的操作已被系统所记录! response.End() end if file1.SaveAs Server.mappath(formPath&filename1)保存文件 上传图片成功 path1= /Carpic/&filename1 else response.write 请选择要插入的图片文件 end if session(qczp)=path1% 图片上传成功. alert(图片上传成功!); opener.document.zc.qczp.value=; window.close(); %判断文件以及文件是否存在则上传 uploadprod2.asp 结束-另外需要一个 上传组件 文件为 zupload.asp 开始-代码如下dim Data_5xsoftClass upload_5xsoft dim objForm,objFile,VersionPublic function Form(strForm) strForm=lcase(strForm) if not objForm.exists(strForm) then Form= else Form=objForm(strForm) end if end functionPublic function File(strFile) strFile=lcase(strFile) if not objFile.exists(strFile) then set File=new FileInfo else set File=objFile(strFile) end if end functionPrivate Sub Class_Initialize dim RequestData,sStart,vbCrlf,sInfo,iInfoStart,iInfoEnd,tStream,iStart,theFile dim iFileSize,sFilePath,sFileType,sFormValue,sFileName dim iFindStart,iFindEnd dim iFormStart,iFormEnd,sFormName Version=上传程序 Version 2.0 set objForm=Server.CreateObject(Scripting.Dictionary) set objFile=Server.CreateObject(Scripting.Dictionary) if Request.TotalBytes1 then Exit Sub set tStream = Server.CreateObject(adodb.stream) set Data_5xsoft = Server.CreateObject(adodb.stream) Data_5xsoft.Type = 1 Data_5xsoft.Mode =3 Data_5xsoft.Open Data_5xsoft.Write Request.BinaryRead(Request.TotalBytes) Data_5xsoft.Position=0 RequestData =Data_5xsoft.Read iFormStart = 1 iFormEnd = LenB(RequestData) vbCrlf = chrB(13) & chrB(10) sStart = MidB(RequestData,1, InStrB(iFormStart,RequestData,vbCrlf)-1) iStart = LenB (sStart) iFormStart=iFormStart+iStart+1 while (iFormStart + 10) 0 then set theFile=new FileInfo 取得文件名 iFindStart = InStr(iFindEnd,sInfo,filename=,1)+10 iFindEnd = InStr(iFindStart,sInfo,1) sFileName = Mid (sinfo,iFindStart,iFindEnd-iFindStart) theFile.FileName=getFileName(sFileName) theFile.FilePath=getFilePath(sFileName) 取得文件类型 iFindStart = InStr(iFindEnd,sInfo,Content-Type: ,1)+14 iFindEnd = InStr(iFindStart,sInfo,vbCr) theFile.FileType =Mid (sinfo,iFindStart,iFindEnd-iFindStart) theFile.FileStart =iInfoEnd theFile.FileSize = iFormStart -iInfoEnd -3 theFile.FormName=sFormName if not objFile.Exists(sFormName) then objFile.add sFormName,theFile end if else 如果是表单项目 tStream.Type =1 tStream.Mode =3 tStream.Open Data_5xsoft.Position = iInfoEnd Data_5xsoft.CopyTo tStream,iFormStart-iInfoEnd-3 tStream.Position = 0 tStream.Type = 2 tStream.Charset =gb2312 sFormValue = tStream.ReadText tStream.Close if objForm.Exists(sFormName) then objForm(sFormName)=objForm(sFormName)&, &sFormValue else objForm.Add sFormName,sFormValue end if end if iFormStart=iFormStart+iStart+1 wend RequestData= set tStream =nothingEnd SubPrivate Sub Class_Terminate if Request.TotalBytes0 then objForm.RemoveAll objFile.RemoveAll set objForm=nothing set objFile=nothing Data_5xsoft.Close set Data_5xsoft =nothing end ifEnd Sub Private function GetFilePath(FullPath) If FullPath Then GetFilePath = left(FullPath,InStrRev(FullPath, ) Else GetFilePath = End If End function Private function GetFileName(FullPath) If FullPath Then GetFileName = mid(FullPath,InStrRev(FullPath, )+1) Else GetFileName = End If End functionEnd ClassClass FileInfo dim FormName,FileName,FilePath,FileSize,FileType,FileStart Private Sub Class_Initialize FileName = FilePath = FileSize = 0 FileStart= 0 FormName = FileType = End Sub Public function SaveAs(FullPath) dim dr,ErrorChar,i SaveAs=true if trim(fullpath)= or FileStart=0 or FileName= or right(fullpath,1)=/ then exit function set dr=CreateObject(Ado

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论