asp怎样上传文件到指定的文件夹并在access中记录路径Word格式文档下载.docx

上传人:b****2 文档编号:5799054 上传时间:2023-05-05 格式:DOCX 页数:16 大小:18.32KB
下载 相关 举报
asp怎样上传文件到指定的文件夹并在access中记录路径Word格式文档下载.docx_第1页
第1页 / 共16页
asp怎样上传文件到指定的文件夹并在access中记录路径Word格式文档下载.docx_第2页
第2页 / 共16页
asp怎样上传文件到指定的文件夹并在access中记录路径Word格式文档下载.docx_第3页
第3页 / 共16页
asp怎样上传文件到指定的文件夹并在access中记录路径Word格式文档下载.docx_第4页
第4页 / 共16页
asp怎样上传文件到指定的文件夹并在access中记录路径Word格式文档下载.docx_第5页
第5页 / 共16页
asp怎样上传文件到指定的文件夹并在access中记录路径Word格式文档下载.docx_第6页
第6页 / 共16页
asp怎样上传文件到指定的文件夹并在access中记录路径Word格式文档下载.docx_第7页
第7页 / 共16页
asp怎样上传文件到指定的文件夹并在access中记录路径Word格式文档下载.docx_第8页
第8页 / 共16页
asp怎样上传文件到指定的文件夹并在access中记录路径Word格式文档下载.docx_第9页
第9页 / 共16页
asp怎样上传文件到指定的文件夹并在access中记录路径Word格式文档下载.docx_第10页
第10页 / 共16页
asp怎样上传文件到指定的文件夹并在access中记录路径Word格式文档下载.docx_第11页
第11页 / 共16页
asp怎样上传文件到指定的文件夹并在access中记录路径Word格式文档下载.docx_第12页
第12页 / 共16页
asp怎样上传文件到指定的文件夹并在access中记录路径Word格式文档下载.docx_第13页
第13页 / 共16页
asp怎样上传文件到指定的文件夹并在access中记录路径Word格式文档下载.docx_第14页
第14页 / 共16页
asp怎样上传文件到指定的文件夹并在access中记录路径Word格式文档下载.docx_第15页
第15页 / 共16页
asp怎样上传文件到指定的文件夹并在access中记录路径Word格式文档下载.docx_第16页
第16页 / 共16页
亲,该文档总共16页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

asp怎样上传文件到指定的文件夹并在access中记录路径Word格式文档下载.docx

《asp怎样上传文件到指定的文件夹并在access中记录路径Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《asp怎样上传文件到指定的文件夹并在access中记录路径Word格式文档下载.docx(16页珍藏版)》请在冰点文库上搜索。

asp怎样上传文件到指定的文件夹并在access中记录路径Word格式文档下载.docx

right"

style="

color:

#666"

汽车照片:

/td>

td>

inputtype="

text"

name="

qczp"

class="

zc_input"

maxlength="

100"

value="

%=session("

)%>

"

readonly>

tdbgcolor="

#E7F8F8"

button"

上传图片"

onClick="

a('

uploadprod.asp'

#666;

width:

60px;

height:

20px;

/tr>

/form>

/table>

上传文件页index.asp结束

uploadprod.asp选择图片上传开始

uploadprod.asp代码如下

!

DOCTYPEhtmlPUBLIC"

-//W3C//DTDXHTML1.0Transitional//EN"

"

http:

//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"

htmlxmlns="

//www.w3.org/1999/xhtml"

head>

metahttp-equiv="

Content-Type"

content="

text/html;

charset=gb2312"

/>

title>

上传图片<

/title>

linkhref="

../images/cnge_wy.css"

rel="

stylesheet"

type="

text/css"

script>

functioncheck()

{

varmf=document.up;

if(mf.image.value.length<

4)

{

alert("

请选择需要上传的图片."

mf.image.focus();

returnfalse;

}

returntrue;

/script>

scriptlanguage="

JavaScript"

if(window.Event)

document.captureEvents(Event.MOUSEUP);

functionnocontextmenu()

{

event.cancelBubble=true

event.returnValue=false;

}

functionnorightclick(e)

if(window.Event)

if(e.which==2||e.which==3)

else

if(event.button==2||event.button==3)

document.oncontextmenu=nocontextmenu;

//forIE5+

document.onmousedown=norightclick;

//forallothers

/head>

bodyonselectstart="

returnfalse"

oncopy="

oncut="

onpaste="

oncontextmenu="

%

response.buffer=true

constpage_level=1

%>

300"

center"

tdcolspan="

2"

height="

25"

font-weight:

bold;

up"

uploadprod2.asp"

enctype="

multipart/form-data"

onsubmit='

returncheck();

'

tdwidth="

50%"

选择图片:

file"

image"

border:

1pxsolid#cdcdcd;

submit"

提交"

Submit"

width:

45px;

18px;

border:

color:

background-color:

#FFFFFF;

reset"

重置"

/body>

/html>

上传文件页uploadprod.asp结束

判断文件以及文件是否存在则上传uploadprod2.asp开始

uploadprod2.asp源代码

图片上传<

%response.buffer=true

session("

path1"

)="

constpage_level=1

--#includefile=zupload.asp-->

AllowFileExtStr="

jpg,gif,png,bmp"

dimID

dimupload,path,file1,filename1

setupload=newupload_5xSoft'

建立上传对象

'

图片上传

formPath="

../Carpic/"

上传图片目录

开始上传图片

setfile1=upload.file("

filename1=year(now())&

-"

&

month(now())&

day(now())&

_"

hour(now())&

Minute(now())&

Second(now())&

right(file1.FileName,4)

iffile1.FileSize>

0then'

如果FileSize>

0说明有文件数据

FileExtName=mid(file1.FileName,InStrRev(file1.FileName,"

."

)+1)

ifCheckFileType(AllowFileExtStr,FileExtName)=Falsethen

response.Writefile1.FileName&

br>

fontcolor=red>

文件:

不允许上传!

上传文件类型有:

&

AllowFileExtStr&

/font>

response.Write"

你的IP:

Replace(Request.ServerVariables("

REMOTE_ADDR"

),"

)&

response.write"

你的操作已被系统所记录!

response.End()

endif

file1.SaveAsServer.mappath(formPath&

filename1)'

保存文件

上传图片成功

path1="

/Carpic/"

filename1

else

请选择要插入的图片文件"

)=path1

p>

图片上传成功.

scriptlanguage=javascript>

图片上传成功!

opener.document.zc.qczp.value="

%=path1%>

;

window.close();

%setfile1=nothing

FunctionCheckFileType(AllowExtStr,FileExtName)

Dimi,AllowArray

AllowArray=Split(AllowExtStr,"

FileExtName=LCase(FileExtName)

CheckFileType=False

Fori=LBound(AllowArray)toUBound(AllowArray)

ifLCase(AllowArray(i))=LCase(FileExtName)then

CheckFileType=True

Next

ifFileExtName="

asp"

orFileExtName="

asa"

aspx"

php"

php3"

php4"

php5"

exe"

then

EndFunction

判断文件以及文件是否存在则上传uploadprod2.asp结束

另外需要一个上传组件文件为zupload.asp开始

代码如下

SCRIPTRUNAT=SERVERLANGUAGE=VBSCRIPT>

dimData_5xsoft

Classupload_5xsoft

dimobjForm,objFile,Version

PublicfunctionForm(strForm)

strForm=lcase(strForm)

ifnotobjForm.exists(strForm)then

Form="

Form=objForm(strForm)

endfunction

PublicfunctionFile(strFile)

strFile=lcase(strFile)

ifnotobjFile.exists(strFile)then

setFile=newFileInfo

setFile=objFile(strFile)

PrivateSubClass_Initialize

dimRequestData,sStart,vbCrlf,sInfo,iInfoStart,iInfoEnd,tStream,iStart,theFile

dimiFileSize,sFilePath,sFileType,sFormValue,sFileName

dimiFindStart,iFindEnd

dimiFormStart,iFormEnd,sFormName

Version="

上传程序Version2.0"

setobjForm=Server.CreateObject("

Scripting.Dictionary"

setobjFile=Server.CreateObject("

ifRequest.TotalBytes<

1thenExitSub

settStream=Server.CreateObject("

adodb.stream"

setData_5xsoft=Server.CreateObject("

Data_5xsoft.Type=1

Data_5xsoft.Mode=3

Data_5xsoft.Open

Data_5xsoft.WriteRequest.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)<

iFormEnd

iInfoEnd=InStrB(iFormStart,RequestData,vbCrlf&

vbCrlf)+3

tStream.Type=1

tStream.Mode=3

tStream.Open

Data_5xsoft.Position=iFormStart

Data_5xsoft.CopyTotStream,iInfoEnd-iFormStart

tStream.Position=0

tStream.Type=2

tStream.Charset="

gb2312"

sInfo=tStream.ReadText

tStream.Close

取得表单项目名称

iFormStart=InStrB(iInfoEnd,RequestData,sStart)

iFindStart=InStr(22,sInfo,"

name="

1)+6

iFindEnd=InStr(iFindStart,sInfo,"

1)

sFormName=lcase(Mid(sinfo,iFindStart,iFindEnd-iFindStart))

如果是文件

ifInStr(45,sInfo,"

filename="

1)>

0then

settheFile=newFileInfo

取得文件名

iFindStart=InStr(iFindEnd,sInfo,"

1)+10

sFileName=Mid(sinfo,iFindStart,iFindEnd-iFindStart)

theFile.FileName=getFileName(sFileName)

theFile.FilePath=getFilePath(sFileName)

取得文件类型

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

ifnotobjFile.Exists(sFormName)then

objFile.addsFormName,theFile

如果是表单项目

tStream.Type=1

Data_5xsoft.Position=iInfoEnd

Data_5xsoft.CopyTotStream,iFormStart-iInfoEnd-3

sFormValue=tStream.ReadText

ifobjForm.Exists(sFormName)then

objForm(sFormName)=objForm(sFormName)&

"

sFormValue

objForm.AddsFormName,sFormValue

wend

RequestData="

settStream=nothing

EndSub

PrivateSubClass_Terminate

ifRequest.TotalBytes>

0then

objForm.RemoveAll

objFile.RemoveAll

setobjForm=nothing

setobjFile=nothing

Data_5xsoft.Close

setData_5xsoft=nothing

PrivatefunctionGetFilePath(FullPath)

IfFullPath<

Then

GetFilePath=left(FullPath,InStrRev(FullPath,"

\"

))

Else

GetFilePath="

EndIf

Endfunction

Privat

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 解决方案 > 学习计划

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2