asp移动手机中实现文件上传|求一个asp手机上传图片的源文件!

① 【急】asp如何文件上传

下面是用ASP写的,已经测试过 文件上传有个非常重要的地方,就是限制格式,严格规定只有什么格式才可以上传否则可能会被黑客利用这些光用DW自动生成是做不出来的 要自己写代码<%if Request.QueryString("submit")="swf_Pic" thenuploadpath=""uploadsize="1024"uploadtype="jpg/gif/png/bmp"Set Uprequest=new UpLoadClass Uprequest.SavePath=uploadpath Uprequest.MaxSize=uploadsize*1024 Uprequest.FileType=uploadtype AutoSave=true Uprequest.open if Uprequest.form("file_Err")<>0 then select case Uprequest.form("file_Err") case 1:str="<div style=""padding-top:5px;padding-bottom:5px;""> <font color=blue>上传不成功!文件超过"&uploadsize&"k [<a href='javascript:history.go(-1)'>重新上传</a>]</font></div>" case 2:str="<div style=""padding-top:5px;padding-bottom:5px;""> <font color=blue>上传不成功!文件格式不对 [<a href='javascript:history.go(-1)']>重新上传</a>]</font></div>" case 3:str="<div style=""padding-top:5px;padding-bottom:5px;""> <font color=blue>上传不成功!文件太大且格式不对 [<a href='javascript:history.go(-1)'>重新上传</a>]</font></div>" end select response.write str else response.write "<script language=""javascript"">parent.form.swf_Pic.value='"&Uprequest.SavePath&Uprequest.Form("file")&"';" response.write "</script>" response.write "<div style=""padding-top:5px;padding-bottom:5px;""> <font color=red>文件上传成功</font> [<a href='javascript:history.go(-1)'>重新上传</a>]</div>" end ifSet Uprequest=nothingend ifresponse.write "<form name=form action=?action=swf_Pic&submit=swf_Pic method=post enctype=multipart/form-data>"response.write "<input type=file name=file class='tx' size='20'> "response.write "<input type=submit name=submit value=上传 class=""tx1"">"response.write "</form>"'============================================================上传函数Class UpLoadClass Private p_MaxSize,p_FileType,p_SavePath,p_AutoSave,p_Error Private objForm,binForm,binItem,strDate,lngTime Public FormItem,FileItem Public Property Get Version Version="Rumor UpLoadClass Version 2.0" End Property Public Property Get Error Error=p_Error End Property Public Property Get MaxSize MaxSize=p_MaxSize End Property Public Property Let MaxSize(lngSize) if isNumeric(lngSize) then p_MaxSize=clng(lngSize) end if End Property Public Property Get FileType FileType=p_FileType End Property Public Property Let FileType(strType) p_FileType=strType End Property Public Property Get SavePath SavePath=p_SavePath End Property Public Property Let SavePath(strPath) p_SavePath=replace(strPath,chr(0),"") End Property Public Property Get AutoSave AutoSave=p_AutoSave End Property Public Property Let AutoSave(byVal Flag) select case Flag case 0: case 1: case 2: case false:Flag=2 case else:Flag=0 end select p_AutoSave=Flag End Property Private Sub Class_Initialize p_Error = -1 p_MaxSize = 153600 p_FileType = "jpg/gif" p_SavePath = "" p_AutoSave = 0 strDate = replace(cstr(Date()),"-","") lngTime = clng(timer()*1000) Set binForm = Server.CreateObject("ADODB.Stream") Set binItem = Server.CreateObject("ADODB.Stream") Set objForm = Server.CreateObject("Scripting.Dictionary") objForm.CompareMode = 1 End Sub Private Sub Class_Terminate objForm.RemoveAll Set objForm = nothing Set binItem = nothing binForm.Close() Set binForm = nothing End Sub Public Sub Open() if p_Error=-1 then p_Error=0 else Exit Sub end if Dim lngRequestSize,binRequestData,strFormItem,strFileItem Const strSplit="'"">" lngRequestSize=Request.TotalBytes if lngRequestSize<1 then p_Error=4 Exit Sub end if binRequestData=Request.BinaryRead(lngRequestSize) binForm.Type = 1 binForm.Open binForm.Write binRequestData Dim bCrLf,strSeparator,intSeparator bCrLf=ChrB(13)&ChrB(10) intSeparator=InstrB(1,binRequestData,bCrLf)-1 strSeparator=LeftB(binRequestData,intSeparator) Dim p_start,p_end,strItem,strInam,intTemp,strTemp Dim strFtyp,strFnam,strFext,lngFsiz p_start=intSeparator+2 Do p_end =InStrB(p_start,binRequestData,bCrLf&bCrLf)+3 binItem.Type=1 binItem.Open binForm.Position=p_start binForm.CopyTo binItem,p_end-p_start binItem.Position=0 binItem.Type=2 binItem.Charset="gb2312" strItem=binItem.ReadText binItem.Close() p_start=p_end p_end =InStrB(p_start,binRequestData,strSeparator)-1 binItem.Type=1 binItem.Open binForm.Position=p_start lngFsiz=p_end-p_start-2 binForm.CopyTo binItem,lngFsiz intTemp=Instr(39,strItem,"""") strInam=Mid(strItem,39,intTemp-39) if Instr(intTemp,strItem,"filename=""")<>0 then if not objForm.Exists(strInam&"_From") then strFileItem=strFileItem&strSplit&strInam if binItem.Size<>0 then intTemp=intTemp+13 strFtyp=Mid(strItem,Instr(intTemp,strItem,"Content-Type: ")+14) strTemp=Mid(strItem,intTemp,Instr(intTemp,strItem,"""")-intTemp) intTemp=InstrRev(strTemp,"\") strFnam=Mid(strTemp,intTemp+1) objForm.Add strInam&"_Type",strFtyp objForm.Add strInam&"_Name",strFnam objForm.Add strInam&"_Path",Left(strTemp,intTemp) objForm.Add strInam&"_Size",lngFsiz if Instr(intTemp,strTemp,".")<>0 then strFext=Mid(strTemp,InstrRev(strTemp,".")+1) else strFext="" end if if left(strFtyp,6)="image/" then binItem.Position=0 binItem.Type=1 strTemp=binItem.read(10) if strcomp(strTemp,chrb(255) & chrb(216) & chrb(255) & chrb(224) & chrb(0) & chrb(16) & chrb(74) & chrb(70) & chrb(73) & chrb(70),0)=0 then if Lcase(strFext)<>"jpg" then strFext="jpg" binItem.Position=3 do while not binItem.EOS do intTemp = ascb(binItem.Read(1)) loop while intTemp = 255 and not binItem.EOS if intTemp < 192 or intTemp > 195 then binItem.read(Bin2Val(binItem.Read(2))-2) else Exit do end if do intTemp = ascb(binItem.Read(1)) loop while intTemp < 255 and not binItem.EOS loop binItem.Read(3) objForm.Add strInam&"_Height",Bin2Val(binItem.Read(2)) objForm.Add strInam&"_Width",Bin2Val(binItem.Read(2)) elseif strcomp(leftB(strTemp,8),chrb(137) & chrb(80) & chrb(78) & chrb(71) & chrb(13) & chrb(10) & chrb(26) & chrb(10),0)=0 then if Lcase(strFext)<>"png" then strFext="png" binItem.Position=18 objForm.Add strInam&"_Width",Bin2Val(binItem.Read(2)) binItem.Read(2) objForm.Add strInam&"_Height",Bin2Val(binItem.Read(2)) elseif strcomp(leftB(strTemp,6),chrb(71) & chrb(73) & chrb(70) & chrb(56) & chrb(57) & chrb(97),0)=0 or strcomp(leftB(strTemp,6),chrb(71) & chrb(73) & chrb(70) & chrb(56) & chrb(55) & chrb(97),0)=0 then if Lcase(strFext)<>"gif" then strFext="gif" binItem.Position=6 objForm.Add strInam&"_Width",BinVal2(binItem.Read(2)) objForm.Add strInam&"_Height",BinVal2(binItem.Read(2)) elseif strcomp(leftB(strTemp,2),chrb(66) & chrb(77),0)=0 then if Lcase(strFext)<>"bmp" then strFext="bmp" binItem.Position=18 objForm.Add strInam&"_Width",BinVal2(binItem.Read(4)) objForm.Add strInam&"_Height",BinVal2(binItem.Read(4)) end if end if objForm.Add strInam&"_Ext",strFext objForm.Add strInam&"_From",p_start intTemp=GetFerr(lngFsiz,strFext) if p_AutoSave<>2 then objForm.Add strInam&"_Err",intTemp if intTemp=0 then if p_AutoSave=0 then strFnam=GetTimeStr() if strFext<>"" then strFnam=strFnam&"."&strFext end if binItem.SaveToFile Server.MapPath(p_SavePath&strFnam),2 objForm.Add strInam,strFnam end if end if else objForm.Add strInam&"_Err",-1 end if end if else binItem.Position=0 binItem.Type=2 binItem.Charset="gb2312" strTemp=binItem.ReadText if objForm.Exists(strInam) then objForm(strInam) = objForm(strInam)&","&strTemp else strFormItem=strFormItem&strSplit&strInam objForm.Add strInam,strTemp end if end if binItem.Close() p_start = p_end+intSeparator+2 loop Until p_start+3>lngRequestSize FormItem=split(strFormItem,strSplit) FileItem=split(strFileItem,strSplit) End Sub Private Function GetTimeStr() lngTime=lngTime+1 GetTimeStr=strDate&lngTime End Function Private Function GetFerr(lngFsiz,strFext) dim intFerr intFerr=0 if lngFsiz>p_MaxSize and p_MaxSize>0 then if p_Error=0 or p_Error=2 then p_Error=p_Error+1 intFerr=intFerr+1 end if if Instr(1,LCase("/"&p_FileType&"/"),LCase("/"&strFext&"/"))=0 and p_FileType<>"" then if p_Error<2 then p_Error=p_Error+2 intFerr=intFerr+2 end if GetFerr=intFerr End Function Public Function Save(Item,strFnam) Save=false if objForm.Exists(Item&"_From") then dim intFerr,strFext strFext=objForm(Item&"_Ext") intFerr=GetFerr(objForm(Item&"_Size"),strFext) if objForm.Exists(Item&"_Err") then if intFerr=0 then objForm(Item&"_Err")=0 end if else objForm.Add Item&"_Err",intFerr end if if intFerr<>0 then Exit Function if VarType(strFnam)=2 then select case strFnam case 0:strFnam=GetTimeStr() if strFext<>"" then strFnam=strFnam&"."&strFext case 1:strFnam=objForm(Item&"_Name") end select end if binItem.Type = 1 binItem.Open binForm.Position = objForm(Item&"_From") binForm.CopyTo binItem,objForm(Item&"_Size") binItem.SaveToFile Server.MapPath(p_SavePath&strFnam),2 binItem.Close() if objForm.Exists(Item) then objForm(Item)=strFnam else objForm.Add Item,strFnam end if Save=true end if End Function Public Function GetData(Item) GetData="" if objForm.Exists(Item&"_From") then if GetFerr(objForm(Item&"_Size"),objForm(Item&"_Ext"))<>0 then Exit Function binForm.Position = objForm(Item&"_From") GetData=binFormStream.Read(objForm(Item&"_Size")) end if End Function Public Function Form(Item) if objForm.Exists(Item) then Form=objForm(Item) else Form="" end if End Function Private Function BinVal2(bin) dim lngValue,i lngValue = 0 for i = lenb(bin) to 1 step -1 lngValue = lngValue *256 + ascb(midb(bin,i,1)) next BinVal2=lngValue End Function Private Function Bin2Val(bin) dim lngValue,i lngValue = 0 for i = 1 to lenb(bin) lngValue = lngValue *256 + ascb(midb(bin,i,1)) next Bin2Val=lngValue End FunctionEnd Class%>

② 如何用ASP制作一个文件上传页面

需求比较清晰,则根据文本框3的内容查找 表2 的 资料ID(唯一) 项 , 看不明白用户登录部分 理清了流程 逐个判断就好上传部分 可以参考http://hi..com/shark258/blog/item/a850d73bc1e79ff114cecb5e.html

③ 求一个asp手机上传图片的源文件!

<% Response.Buffer = true Server.ScriptTimeOut=9999999 On Error Resume next%><!doctype html public "-//W3C//dtd XHTML 1.0 transitional//en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><meta http-equiv="Content-Language" content="zh-cn" /><meta content="all" name="robots" /> <meta name="author" content="木目,Woodeye" /><meta name="description" content="木目asp文件上传工具" /> <meta name="keywords" content="木目,asp,Upload,文件上传" /><style type="text/css"><!–body,input {font-size:12px;}–></style><title>木目asp文件上传工具</title></head><body id="body"><% ExtName = "jpg,gif,png,txt,rar,zip,doc,bmp" '允许扩展名 SavePath = "image" '保存路径 If Right(SavePath,1)<>"/" Then SavePath=SavePath&"/" '在目录后加(/) CheckAndCreateFolder(SavePath) UpLoadAll_a = Request.TotalBytes '取得客户端全部内容 If(UpLoadAll_a>0) Then Set UploadStream_c = Server.CreateObject("ADODB.Stream") UploadStream_c.Type = 1 UploadStream_c.Open UploadStream_c.Write Request.BinaryRead(UpLoadAll_a) UploadStream_c.Position = 0 FormDataAll_d = UploadStream_c.Read CrLf_e = chrB(13)&chrB(10) FormStart_f = InStrB(FormDataAll_d,CrLf_e) Formend_g = InStrB(FormStart_f+1,FormDataAll_d,CrLf_e) Set FormStream_h = Server.Createobject("ADODB.Stream") FormStream_h.Type = 1 FormStream_h.Open UploadStream_c.Position = FormStart_f + 1 UploadStream_c.CopyTo FormStream_h,Formend_g-FormStart_f-3 FormStream_h.Position = 0 FormStream_h.Type = 2 FormStream_h.CharSet = "GB2312" FormStreamText_i = FormStream_h.Readtext FormStream_h.Close Filename_j = Mid(FormStreamText_i,InstrRev(FormStreamText_i,"\")+1,Formend_g) If(CheckFileExt(Filename_j,ExtName)) Then SaveFile = Server.MapPath(SavePath & Filename_j) If Err Then Response.Write "文件上传: <span style=""color:red;"">文件上传出错!</span> <a href=""" & Request.ServerVariables("url") &""">重新上传文件</a><br />" Err.Clear Else SaveFile = CheckFileExists(SaveFile) k=Instrb(FormDataAll_d,CrLf_e&CrLf_e)+4 l=Instrb(k+1,FormDataAll_d,leftB(FormDataAll_d,FormStart_f-1))-k-2 FormStream_h.Type=1 FormStream_h.Open UploadStream_c.Position=k-1 UploadStream_c.CopyTo FormStream_h,l FormStream_h.SaveToFile SaveFile,2 SaveFilename = Mid(SaveFile,InstrRev(SaveFile,"\")+1) Response.write "文件上传: <span style=""color:red;"">" & SaveFilename & " </span>文件上传成功! <a href=""" & Request.ServerVariables("url") &""">继续上传文件</a><br />" end If Else Response.write "文件上传: <span style=""color:red;"">文件格式不正确!</span> <a href=""" & Request.ServerVariables("url") &""">重新上传文件</a><br />" end If Else%><script language="Javascript"><!–function ValidInput(){ if(document.upform.upfile.value=="") { alert("请选择上传文件!") document.upform.upfile.focus() return false } return true}// –></script><form action='<%= Request.ServerVariables("url") %>' method='post' name="upform" onsubmit="return ValidInput()" enctype="multipart/form-data">文件上传:<input type='file' name='upfile' size="40"> <input type='submit' value="上传"></form><% end if Set FormStream_h = Nothing UploadStream.Close Set UploadStream = Nothing%></body></html><% '判断文件类型是否合格 Function CheckFileExt(Filename,ExtName) '文件名,允许上传文件类型 FileType = ExtName FileType = Split(FileType,",") For i = 0 To Ubound(FileType) If LCase(Right(Filename,3)) = LCase(FileType(i)) then CheckFileExt = true Exit Function Else CheckFileExt = False end if next end Function '检查上传文件夹是否存在,不存在则创建文件夹 Function CheckAndCreateFolder(FolderName) fldr = Server.Mappath(FolderName) Set fso = CreateObject("Scripting.FileSystemObject") If Not fso.FolderExists(fldr) Then fso.CreateFolder(fldr) end If Set fso = Nothing end Function'检查文件是否存在,重命名存在文件Function CheckFileExists(FileName) Set fso=Server.CreateObject("Scripting.FileSystemObject") If fso.FileExists(SaveFile) Then i=1 msg=True Do While msg CheckFileExists = Replace(SaveFile,Right(SaveFile,4),"_" & i & Right(SaveFile,4)) If not fso.FileExists(CheckFileExists) Then msg=False end If i=i+1 Loop Else CheckFileExists = FileName End If Set fso=NothingEnd Function%>

④ asp中怎么上传文件

post.asp 做为发表页,其中引用choose.asp作图片上传 choose.asp 提供浏览选择图片,提交数据给upload.aspupload.asp中的asp程序负责上传writepost.asp 负责将文本和图片名一起写入数据库1--------filename="上传后获得的文件名",然后upload.asp自动跳转choose.asp 页,加上参数,格式为:choose.asp?filename="上传后获得的文件名"然后你用Request.QueryString("filename")即可获取文件名,然后就能将post.asp中书写的文本一起提交给wirtepost.asp 保存了2-----------也可以用session来保存文件名,session("filename")="上传后获得的文件名",然后直接跳转回choose.asp,在post.asp页提供的表单中写完文本,提交给writepost.asp 保存,因为用的session所以不必担心文件名丢失那最后在writepost.asp 中,如果用session,完成保存动作后,要清空session("filename")哦

⑤ ASP 怎么实现文件上传

文件上传分为“组件上传”和“无组件上传”。组件上传需要你为服务器安装注册组件,上传速度快,但需要你有服务器的管理员权限。无组件上传使用asp的内置对象,不需要额外安装组件,但是速度慢,不适合上传大文件。但是一般来说,asp的表单只能单独提交一个文件。不能多文件上传。因此多数多文件上传都不够美观。幸好FLASH发展到9之后出现了多文件上传的支持。我们可以用FLASH来做上传界面。给你个flash多文件上传的源码地址,毫无疑问,这个是可以与ASP结合的很好。http://www.codefans.net/soft/3773.shtml 楼主补充提问里的图片貌似是单文件上传吧?要修改成多文件上传挺困难的。

⑥ ASP文件上传原理分析及实现实例

摘要 在基于/的应用环境中 上传各种类型的文件一直是困扰用户文件管理应用的难题之一 在HTTP中上传文件有三种机制 RFC PUT和WebDAV 常用的实现方法是利用在RFC 中引入的一个新类型 File以及ADO Stream对象 本文对上述上传方法及实现原理作了论述 并给出了具体解决实例 ASP FILE对象

当前 基于/模式的应用比较流行 当用户需要将文件传输到上时 常用方法之一是运行FTP并将每个用户的FTP默认目录设为用户的Web主目录 这样用户就能运行FTP客户程序并上传文件到指定的 Web目录 这就要求用户必须懂得如何使用FTP客户程序 因此 这种解决方案仅对熟悉FTP且富有经验的用户来说是可行的 如果我们能把文件上传功能与Web集成 使用户仅用Web就能完成上传任务 这对于他们来说将是非常方便的 但是 一直以来 由于File System Object的仅能传送文本文件的局限 所以ASP最大的难题就是文件上传问题 下面介绍的就是如何在基于HTTP协议的网页中实现文件的上传

一 通过HTTP上传的三种机制

通过HTTP上传有三种机制 RFC PUT 和 WebDAV

PUT 是在HTTP 引入了一个新的HTTP动词 当web收到一个HTTP PUT和对象名字 它将会验证用户 接收HTTP流的内容 并把它直接存入web 由于这可能会对一个web站点造成破坏 并且还会失去HTTP最大的优势 可编程性 在PUT的情况下 自己处理请求 没有空间让CGI或者ASP应用程序介入 唯一让你的应用程序捕获PUT的方法是在低层操作 ISAPI过滤层 由于相应的原因 PUT的应用很有限

而WebDAV允许web内容的分布式认证与翻译 它引入了几种新的HTTP动词 允许通过HTTP上传 锁定/解锁 登记/检验web内容 Office 中的 Save to web 就是通过WebDAV来实现的 如果你所感兴趣的一切都是上传内容 WebDAV应用得非常出色 它解决了很多问题 然而 如果你需要在你的web应用程序里面上传文件 WebDAV对你就毫无用处可言 象HTTP PUT一样 那些WebDAV的动词是被解释的 而不是web应用程序 你需要工作在ISAPI过滤层来访问WebDAV的这些动词 并在你的应用程序中解释内容

RFC () 最终被W C在HTML 中接受前 是作为一种建议标准 它是一种非常简单但是功能很强大的想法 在表单字段中定义一个新类型 <INPUT TYPE= FILE >

并且在表单本身加入了不同的编码方案 不再使用典型的 <FORM ACTION= formproc asp METHOD= POST > 而是使用 <FORM ACTION= formproc asp METHOD= POST ENCTYPE= multipart/form data >

这种编码方案在传送大量数据的时候 比起缺省的 application/x url encoded 表单编码方案 显得效率要高得多 URL编码只有很有限的字符集 使用任何超出字符集的字符 必须用 %nn 代替 这里的nn表示相应的 个十六进制数字 例如 即使是普通的空格字符也要用 % 代替 而RFC 使用多部分MIME编码 就象通常在e mail消息中看到的那样 不编码来传送大量数据 而只是在数据周围加上很少的简单但实用的头部 主要的厂商都采用了建议的 浏览…… 按钮 用户能很容易的使用本地 打开文件…… 对话框选择要上传的文件

RFC 仍然将大多数文件上传的灵活方法留给了你的web应用程序 PUT用得很有限 WebDAV对内容的作者很有用 比如FrontPage用户 但是对想在web应用程序中加入文件上传的web开发者来说很少用到 因此 RFC 是在web应用程序中加入文件上传的最好的办法

在实际应用中 免费提供了Posting Acceptor ASP不懂 multipart/form data 编码方案 取而代之 提供了Posting Acceptor Posting Acceptor是一种在上传完成后 接受REPOST到一个ASP页的ISAPI应用程序

Sofare Artisans的SA FileUp是最早的商业Active Server之一 几经改进 现在作为一个纯粹的ASP存在

二 基于ASP的文件上传实现原理分析

基本原理是 采用ADO Stream对象的BinaryRead方法将FORM中的所有数据读出 从中截取出所需的文件数据 以二进制文件方式存盘

下面是上传文件页面的一个例子() <><body><form name= Upload Method= Post Enctype= multipart/form data Action= Upload asp ><input type= file name= FileName ><INPUT TYPE= Submit VALUE= Upload ></TD></form></body></>

程序中使用了文件对象 这样在Upload asp中采用BinaryRead方法读来的原始数据就不仅仅是选择的文件本身的数据 还包含该文件在用户硬盘上的路径 类型 提交页面的表单等相关信息的描述 这样我们就需从中提取出文件的具体内容 根据分析 数据的头部信息与数据的分界线是两对回车换行符 尾部也有分隔信息 我们可以采用类似以下的方法获取文件数据 Dim FormData FormSize DataStart CLStr DivStrFormSize=Request TotalBytesFormData=Request BinaryRead(FormSize)CLStr=ChrB( )&ChrB( )DataStart=InStrB(FormData CLStr&CLStr)+ 是两对回车换行符的长度DivStr=LeftB(FormData InStrB(FormData CLStr) )DataSize=InStrB(DataStart+ FormData DivStr) DataStart FormData=MidB(FormData DataStart DataSize) FormData就是文件的内容了 中间根据需要 可进行相应的处理 最后的工作就是将文件保存了 保存的方法可以有两种 一种是利用VB或VC之类程序中的二进制文件操作方法 在工程中加入适当的类型库 最终编译成DLL文件 使用时再将该DLL文件注册就可以了 文件存贮程序如下 Public Function SaveFile(Pathname As String) As String Dim objContext As ObjectContext Dim objRequest As Request Set objContext=GetObjectContext() Set objRequest=objContext( Request ) 以下的一段代码是进行文件存贮的有关操作Dim FormData() As Byte CLStr DivStr Dim DataStart As Long DataSize As Long DataSize=objRequest TotalBytes Redim FormData(DataSize ) FormData=objRequest BinaryRead(DataSize) CLStr=ChrB( ) & ChrB( ) DataStart=InStrB(FormData CLStr & CLStr)+ DivStr=LeftB(FormData InStrB(FormData CLStr) ) DataSize=InStrB(DataStart+ FormData DivStr) DataStart FormData=MidB(FormData DataStart DataSize) 创建一个二进制文件并将FormData写入其中 Open Pathname For Binary As Put # FormData Close # SaveFile= OK! End Function 第二种方法是利用ADO STREAM中提供的二进制文件操作方法来完成 保存文件的语句是 StreamOBJ SaveToFile (fileName ) 在 这种操作中 我们可以将有关的操作存放在一个类文件中 在应用时 直接将该类文件包含在ASP程序中就可以了 具体处理方法 请参阅有关介绍 三.文件上传实现方法实例 实现文件上传可使用或无方式 对于类 比如说microsoft posting acceptor(简称mpa) 就是公司发布的一个免费 这类的安装也比较方便 对于的mpa 运行它的安装文件就可以了 而一般的dll形式的 我们则需要进行注册 例如 要使用aspcnUP dll 只要在Window 上执行regsvr [path]aspcnUP dll 系统出现注册成功的信息提示就可以使用该了 对于无类 如的无上传类 upload_ xsoft 在使用时 只要在处理程序中包含以下的语句就可以了 <! #include FILE= upload inc >set upload=new upload_ xSoft 建立上传对象 有关的属性与操作方法 请参阅该的使用手册 下面是詀spcnUP dll为例 上传部分类型文件的源代码(upload asp) <% @ language= vbscript Set fileUP=Server CreateObject( aspcn Upload )fileUP Maxsize= fileUP Path= d:upfile fileUP UploadFor i= to fileUP Countfieldname=fileUP FieldName(i)If fileUP FileType(fieldname)= zip Or ileUP FileType(fieldname)= rar ThenfileUP Save fieldnameEnd If NextSet fileUP=Nothing%> 四.结束语 应用模式还在快速地发展着 在ASP.NET中 已经内置了文件上传的功能 使用非常简单方便 作为一种全新的技术 ASP.NET并不只是ASP的简单升级 它是一个用于Web开发的全新框架 其中包含了许多新的特性 ASP.NET提供了更易于编写 结构更清晰的代码 利用这些代码我们将会更容易地进行再利用和共享 从而开发出更多更实用的程序来 lishixin/Article/program/net/201311/13562

⑦ asp如何实现文件上传功能

基本原理是:采用ADO Stream对象的BinaryRead方法将FORM中的所有数据读出,从中截取出所需的文件数据,以二进制文件方式存盘。

下面是上传文件页面的一个例子:

<html>

<body>

<form name="Upload" Method="Post" Enctype="multipart/form-data" Action="Upload.asp">

<input type="file" name="FileName">

<INPUT TYPE="Submit" VALUE="Upload"></TD>

</form>

</body>

</html>

(7)asp移动手机中实现文件上传扩展阅读

几种文件上传技术的比较

1、基于HTTP协议

该方法需要编程者利用第三方软件,如DELPHI、VB等,在应用程序中先进行HTTP协议编程,然后将待上传文件内容按HTTP协议的格式打包,最后向WEB服务器发送上传的请求报文,从而实现文件的上传。

因为DELPHI和VB不能编写完整的WEB网络程序,只能编写WEB小应用程序,因此,该方法只用于功能受限的网络应用。

2、基于VB(或DELPHI等)开发的文件上传组件

该方法利用VB(或DELPHI等编程语言)开发ASP服务器组件,实现特定的文件上传服务。它首先利用ASP表单功能将文件(二进制格式)从用户端上传到服务器端,然后使用VB开发的组件,对二进制文件进行处理,成为可以正常读写的文件。

该方法要求编程者不仅掌握ASP语言,而且还能利用VB等第三方语言进行组件编程,增加了开发的难度。

3、基于数据库技术

该方法和上个方法有类似之处。不同的地方在于对上传的二进制文件的处理上。它使用数据库来保存二进制文件。无论是小型数据库还是大型数据库都提供了存储二进制数据的数据类型,只要以Append Chunk方式将数据存入相应的字段就可以了。

该方法虽然简单可行,但是因为每次上传的文件大小都是不一样的,因此,会对数据库的空间造成很大的浪费,降低了数据的访问速度;并且使得文件只能在数据库环境下进行访问,造成了很大的不便。

⑧ asp中怎么实现文件的上传

单用file控件是不能实现上传文件的。网上有很多无组件上传的资料,例如无惧类,可以网络一下。下载的时候,把你存放文件的路径传递过来,提供个连接一般就可以了,但如果是doc之类的文件,IE可能会自动调用相应的软件直接打开而不是下载。

⑨ 如果实现用ASP来上传文件

文件上传必须通过 form 以post方式传递(因为post的内容不是文件名,而是文件)用url参数传文件名是没有文件的。网络的安全其一就是不能操作客户的文件。


赞 (0)