当前位置:首页 » 文件管理 » asp上传下载代码

asp上传下载代码

发布时间: 2022-12-14 02:19:49

1. 求!!ASP上传下载源码,那位大侠提供下,小弟感激不尽。。。

风云ASP(组件&无组件)上传 [2006-11-30]

最新的组件发布地址是:http://www.zope.org/Members/Rimifon/FyUpload.sct,需要最新版本,请留意该文件的最后更新时间

有组件上传:
第一次使用需要右键“FyUpload.sct”文件 - 注册
创建对象:Set Upload = Server.CreateObject("Rimifon.Upload")

无组件上传:
创建对象:Set Upload = GetObject("script:组件地址#Upload")
组件地址为硬盘绝对路径,也可以为http完整路径(针对IIS 5.0)

简单测试代码:
/-*- Upload.html -*-/
<form method=post action=Upload.asp enctype=multipart/form-data>
<input name=MyFile type=file>
<input type=submit></form>

/-*- Upload.asp -*-/
<%Set Upload = Server.CreateObject("Rimifon.Upload")
Upload.ReadForm 204800 ' 设置缓冲区大小,Windows 2003默认不允许超过204800,否则会上传失败。
Upload.SaveFile ' 保存文件到当前目录,如需保存到Upload目录下,则使用SaveFile "Upload"
Upload.Dispose ' 释放内存
Set Upload = Nothing%>

其它详细属性和方法:
Upload.Charset ' 当页面编码为utf-8时请设置该值为"UTF-8",默认为"gb2312"
Upload.Filter ' 设置允许上传的文件类型,默认为“rar|zip|txt|gif|jpg|bmp|htm|html|swf|mht”,为空则允许任何格式文件上传。
Upload.MaxSize ' 设置单个文件允许上传的最大大小(Bytes),如不限制则为0(默认为0)
Upload.Field ' 客户端提交的表单元素;
针对文本元素:Upload.Field.test.Value ' 读出表单元素"test"的值
针对文件元素:
Upload.Field.MyFile.FilePath ' 读出文件在客户端的位置
Upload.Field.MyFile.SourceName ' 读出文件的源文件名
Upload.Field.MyFile.FileName ' 文件保存在服务器的文件名
Upload.Field.MyFile.FileSize ' 读出文件大小
Upload.Field.MyFile.FileType ' 读出文件的Mime类型
Upload.Field.MyFile.SavePath ' 获取或设置该文件保存位置的绝对路径
Upload.Field.MyFile.Message ' 服务器拒绝该文件时返回的信息
Upload.Field.MyFile.Value ' 文件数据(unicode字符)
数据库时直接使用rs("FileData").AppendChunk Upload.Field.MyFile.Value的方式即可
Upload.Form("test") ' 返回表单元素"test"的值,是Upload.Field.test.Value的简化读取方式,当不存在"test"元素时返回空值。
Upload.ReadForm FormSize, ProgID
读取表单,FormSize为缓冲区大小,默认为0,推荐在204800以下(可解决2003下不能上传大文件的问题)。
提供参数2(ProgID)会为上传提供进度数据(Application),需要上传进度条时才用到这个参数。
总文件大小:Application(ProgID + "_TotalBytes")
已上传数据量:Application(ProgID + "_ReadBytes")
进度条统计完毕后,建议清除这两个变量:Application.Contents.Remove(ProgID + "_TotalBytes")
Upload.SaveFile SavePath
保存文件到当前目录的SavePath(该目录必需存在)下,默认为当前目录。
Upload.Dispose 释放内存

附带代码:
Test_00.asp vbs(asp) 调用简单示例
Test_01.asp 指定保存位置测试

2. 请问用ASP如何能实现文件的上传和下载

<table width=700 align=center><tr><td>
<body topmargin="10" bgcolor="#ffffff">
<%

Dim sStyleID, sUploadDir, sCurrDir, sDir

sPosition = sPosition & "上传文件管理"

Call Header()
Call Content()
Call Footer()

Sub Content()
If IsObjInstalled("Scripting.FileSystemObject") = False Then
Response.Write "此功能要求服务器支持文件系统对象(FSO),而你当前的服务器不支持!"
Exit Sub
End If

' 初始化传入参数
Call InitParam()

Select Case sAction
Case "DELALL" ' 删除所有文件
Call DoDelAll()
Case "DEL" ' 删除指定文件
Call DoDel()
Case "DELFOLDER" ' 删除文件夹
Call DoDelFolder()
End Select

' 显示文件列表
Call ShowList()
End Sub

' UploadFile目录下的所有文件列表
Sub ShowList()

If sCurrDir = "" Then Exit Sub

Response.Write "<table border=1 style='border-collapse: collapse' bordercolor='#C0C0C0' cellpadding=3 cellspacing=0>" & _
"<form action='?id=" & sStyleID & "&dir=" & sDir & "&action=del' method=post name=myform>" & _
"<tr align=center>" & _
"<td width=50 height=25 background='../images/bj5.jpg' style='color:ffffff'>类型</th>" & _
"<td width=140 background='../images/bj5.jpg' style='color:ffffff'>文件地址</th>" & _
"<td width=100 background='../images/bj5.jpg' style='color:ffffff'>大小</th>" & _
"<td width=130 background='../images/bj5.jpg' style='color:ffffff'>最后访问</th>" & _
"<td width=130 background='../images/bj5.jpg' style='color:ffffff'>上传日期</th>" & _
"<td width=30 background='../images/bj5.jpg' style='color:ffffff'>删除</th>" & _
"</tr>"

Dim sCurrPage, nCurrPage, nFileNum, nPageNum, nPageSize
sCurrPage = Trim(Request("page"))
nPageSize = 20
If sCurrpage = "" Or Not IsNumeric(sCurrPage) Then
nCurrPage = 1
Else
nCurrPage = CLng(sCurrPage)
End If

Dim oFSO, oUploadFolder, oUploadFiles, oUploadFile, sFileName

Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
On Error Resume Next
Set oUploadFolder = oFSO.GetFolder(Server.MapPath(sCurrDir))
If Err.Number>0 Then
Response.Write "</table>无效的目录!"
Exit Sub
End If

If sDir <> "" Then
Response.Write "<tr align=center>" & _
"<td><img border=0 src='sysimage/file/folderback.gif'></td>" & _
"<td align=left colspan=5><a href=""?id=" & sStyleID & "&dir="
If InstrRev(sDir, "/") > 1 Then
Response.Write Left(sDir, InstrRev(sDir, "/") - 1)
End If
Response.Write """>返回上一级目录</a></td></tr>"
End If

Dim oSubFolder
For Each oSubFolder In oUploadFolder.SubFolders
Response.Write "<tr align=center>" & _
"<td><img border=0 src='sysimage/file/folder.gif'></td>" & _
"<td align=left colspan=4><a href=""?id=" & sStyleID & "&dir="
If sDir <> "" Then
Response.Write sDir & "/"
End If
Response.Write oSubFolder.Name & """>" & oSubFolder.Name & "</a></td>" & _
"<td><a href='?id=" & sStyleID & "&dir=" & sDir & "&action=delfolder&foldername=" & oSubFolder.Name & "'>删除</a></td></tr>"
Next

Set oUploadFiles = oUploadFolder.Files

nFileNum = oUploadFiles.Count
nPageNum = Int(nFileNum / nPageSize)
If nFileNum Mod nPageSize > 0 Then
nPageNum = nPageNum+1
End If
If nCurrPage > nPageNum Then
nCurrPage = 1
end If

Dim i
i = 0
For Each oUploadFile In oUploadFiles
i = i + 1
If i > (nCurrPage - 1) * nPageSize And i <= nCurrPage * nPageSize Then
sFileName = oUploadFile.Name
Response.Write "<tr align=center>" & _
"<td>" & FileName2Pic(sFileName) & "</td>" & _
"<td align=center><a href=""" & sCurrDir & sFileName & """ target=_blank>"
if right(sFileName,3)="jpg" or right(sFileName,3)="JPG" or right(sFileName,3)="gif" or right(sFileName,3)="GIF" or right(sFileName,3)="BMP" or right(sFileName,3)="bmp" or right(sFileName,3)="png" or right(sFileName,3)="PNG" then
Response.Write "<img border=0 width=80 height=60 src="&sCurrDir& sFileName&" ><BR>"
end if
Response.Write sFileName & "</a></td>" & _
"<td>" & oUploadFile.size & " B </td>" & _
"<td>" & oUploadFile.datelastaccessed & "</td>" & _
"<td>" & oUploadFile.datecreated & "</td>" & _
"<td><input type=checkbox name=delfilename value=""" & sFileName & """></td></tr>"
Elseif i > nCurrPage * nPageSize Then
Exit For
End If
Next
Set oUploadFolder = Nothing
Set oUploadFiles = Nothing

If nFileNum <= 0 Then
Response.Write "<tr><td colspan=6>指定目录下现在还没有文件!</td></tr>"
End If
Response.Write "</table>"

If nFileNum > 0 Then
' 分页
Response.Write "<table border=0 cellpadding=3 cellspacing=0 width='100%'><tr><td align=center>"
If nCurrPage > 1 Then
Response.Write "<a href='?id=" & sStyleID & "&dir=" & sDir & "&page=1'>首页</a><a href='?id=" & sStyleID & "&dir=" & sDir & "&page="& nCurrPage - 1 & "'>上一页</a>"
Else
Response.Write "首页上一页"
End If
If nCurrPage < i / nPageSize Then
Response.Write "<a href='?id=" & sStyleID & "&dir=" & sDir & "&page=" & nCurrPage + 1 & "'>下一页</a><a href='?id=" & sStyleID & "&dir=" & sDir & "&page=" & nPageNum & "'>尾页</a>"
Else
Response.Write "下一页尾页"
End If
Response.Write "共<b>" & nFileNum & "</b>个页次:<b><span class=highlight2>" & nCurrPage & "</span>/" & nPageNum & "</b><b>" & nPageSize & "</b>个文件/页"
Response.Write "</td></tr></table>"
End If

Response.Write "<p align=center><input type=submit name=b value=' 删除选定的文件 '> <input type=button name=b1 value=' 清空所有文件 ' onclick=""javascript:if (confirm('你确定要清空所有文件吗?')) {location.href='admin_uploadfile.asp?id=" & sStyleID & "&dir=" & sDir & "&action=delall';}""></p></form>"

End Sub

' 删除指定的文件
Sub DoDel()
On Error Resume Next
Dim sFileName, oFSO, sMapFileName
Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
For Each sFileName In Request.Form("delfilename")
sMapFileName = Server.MapPath(sCurrDir & sFileName)
If oFSO.FileExists(sMapFileName) Then
oFSO.DeleteFile(sMapFileName)
End If
Next
Set oFSO = Nothing
End Sub

' 删除所有的文件
Sub DoDelAll()
On Error Resume Next
Dim sFileName, oFSO, sMapFileName, oFolder, oFiles, oFile
Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder(Server.MapPath(sCurrDir))
Set oFiles = oFolder.Files
For Each oFile In oFiles
sFileName = oFile.Name
sMapFileName = Server.MapPath(sCurrDir & sFileName)
If oFSO.FileExists(sMapFileName) Then
oFSO.DeleteFile(sMapFileName)
End If
Next
Set oFile = Nothing
Set oFolder = Nothing
Set oFSO = Nothing
End Sub

' 删除文件夹
Sub DoDelFolder()
On Error Resume Next
Dim sFolderName, oFSO, sMapFolderName
Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
sFolderName = Trim(Request("foldername"))
sMapFolderName = Server.Mappath(sCurrDir & sFolderName)
If oFSO.FolderExists(sMapFolderName) = True Then
oFSO.DeleteFolder(sMapFolderName)
End If
Set oFSO = Nothing
End Sub

' 检测服务器是否支持某一对象
Function IsObjInstalled(strClassString)
On Error Resume Next
IsObjInstalled = False
Err = 0
Dim xTestObj
Set xTestObj = Server.CreateObject(strClassString)
If 0 = Err Then IsObjInstalled = True
Set xTestObj = Nothing
Err = 0
End Function

' 按文件名取图
Function FileName2Pic(sFileName)
Dim sExt, sPicName
sExt = UCase(Mid(sFileName, InstrRev(sFileName, ".")+1))
Select Case sExt
Case "TXT"
sPicName = "txt.gif"
Case "CHM", "HLP"
sPicName = "hlp.gif"
Case "DOC"
sPicName = "doc.gif"
Case "PDF"
sPicName = "pdf.gif"
Case "MDB"
sPicName = "mdb.gif"
Case "GIF"
sPicName = "gif.gif"
Case "JPG"
sPicName = "jpg.gif"
Case "BMP"
sPicName = "bmp.gif"
Case "PNG"
sPicName = "pic.gif"
Case "ASP", "JSP", "JS", "PHP", "PHP3", "ASPX"
sPicName = "code.gif"
Case "HTM", "HTML", "SHTML"
sPicName = "htm.gif"
Case "ZIP"
sPicName = "zip.gif"
Case "RAR"
sPicName = "rar.gif"
Case "EXE"
sPicName = "exe.gif"
Case "AVI"
sPicName = "avi.gif"
Case "MPG", "MPEG", "ASF"
sPicName = "mp.gif"
Case "RA", "RM"
sPicName = "rm.gif"
Case "MP3"
sPicName = "mp3.gif"
Case "MID", "MIDI"
sPicName = "mid.gif"
Case "WAV"
sPicName = "audio.gif"
Case "XLS"
sPicName = "xls.gif"
Case "PPT", "PPS"
sPicName = "ppt.gif"
Case "SWF"
sPicName = "swf.gif"
Case Else
sPicName = "unknow.gif"
End Select
FileName2Pic = "<img border=0 src='sysimage/file/" & sPicName & "'>"
End Function

' ===============================================
' 初始化下拉框
' v_InitValue : 初始值
' s_Sql : 从数据库中取值时,select name,value from table
' s_AllName : 空值的名称,如:"全部","所有","默认"
' ===============================================
Function InitSelect(v_InitValue, s_Sql, s_AllName)
Dim i
InitSelect = ""
If s_AllName <> "" Then
InitSelect = InitSelect & "<option value=''>" & s_AllName & "</option>"
End If
oRs.Open s_Sql, oConn, 0, 1
Do While Not oRs.Eof
InitSelect = InitSelect & "<option value=""" & inHTML(oRs(1)) & """"
If CStr(oRs(1)) = CStr(v_InitValue) Then
InitSelect = InitSelect & " selected"
End If
InitSelect = InitSelect & ">" & outHTML(oRs(0)) & "</option>"
oRs.MoveNext
Loop
oRs.Close
End Function

' ===============================================
' 初始化传入参数
' ===============================================
Function InitParam()
sStyleID = Trim(Request("id"))
sUploadDir = ""
If IsNumeric(sStyleID) = True Then
sSql = "select S_UploadDir from eWebEditor_Style where S_ID=" & sStyleID
oRs.Open sSql, oConn, 0, 1
If Not oRs.Eof Then
sUploadDir = oRs(0)
End If
oRs.Close
End If
If sUploadDir = "" Then
sStyleID = ""
Else
sUploadDir = Replace(sUploadDir, "\", "/")
If Right(sUploadDir, 1) <> "/" Then
sUploadDir = sUploadDir & "/"
End If
End If
sCurrDir = sUploadDir

' 样式下的目录
sDir = Trim(Request("dir"))
If sDir <> "" Then
If CheckValidDir(Server.Mappath(sUploadDir & sDir)) = True Then
sCurrDir = sUploadDir & sDir & "/"
Else
sDir = ""
End If
End If
End Function

' ===============================================
' 检测目录的有效性
' ===============================================
Function CheckValidDir(s_Dir)
Dim oFSO
Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
CheckValidDir = oFSO.FolderExists(s_Dir)
Set oFSO = Nothing
End Function
%>
</td></tr></table>

3. asp关于文件的上传和下载功能

先说明一下:
一、组件上传,在使用方法上,使用代码少,更安全,更容易控制,并且功能更强大,比如可以实现控制上传图片的尺寸,可以实现真实的上传进度条等,并且上传图片后可以进行对图片进行编辑等。但缺点是要求服务必需安装这个组件,如果是自己的服务器还好办,如果你是租用空间的话,那么最好放弃组件上传吧。
二、无组件上传,在使用上相对稍复杂一点,需要你到网上下载一个“ASP无组件上传类”(一般为一个.inc文件),不能对图片进行处理,只可以控制上传的文件类型,文件大小等,优点是对服务器无要求,租用的服务器空间绝大多数都可以使用。

综上所述,对于一般小站或企业网站,上传文件不多,文件不大,要求不高的都使用无组件上传。

目前较流行的 无组件上传类有:
化境ASP无组件上传类
风声ASP无组件上传类
艾恩ASP无组件上传类
等,你在网络里搜索以上关键字,找到官方网站,可以免费下载相关上传类,并且有详细用法说明,及例子。

4. 求:简单asp上传下载代码

化境ASP无组件上传 V2.0
上传至指定文件夹
上传至数据库

以上三种需要的话发email给我。
先来一个吧
upfile.asp
----------------------------------------------
<%OPTION EXPLICIT%>
<%Server.ScriptTimeOut=5000%>
<!--#include FILE="upload_5xsoft.inc"-->
<html>
<head>
<title>文件上传</title>
</head>
<body>
<br>化境文件上传!<hr size=1 noshadow width=300 align=left><br><br>
<%
dim upload,file,formName,formPath,iCount
set upload=new upload_5xsoft ''建立上传对象

response.write upload.Version&"<br><br>" ''显示上传类的版本

if upload.form("filepath")="" then ''得到上传目录
HtmEnd "请输入要上传至的目录!"
set upload=nothing
response.end
else
formPath=upload.form("filepath")
''在目录后加(/)
if right(formPath,1)<>"/" then formPath=formPath&"/"
end if

iCount=0
for each formName in upload.objForm ''列出所有form数据
response.write formName&"="&upload.form(formName)&"<br>"
next

response.write "<br>"
for each formName in upload.objFile ''列出所有上传了的文件
set file=upload.file(formName) ''生成一个文件对象
if file.FileSize>0 then ''如果 FileSize > 0 说明有文件数据
file.SaveAs Server.mappath(formPath&file.FileName) ''保存文件
response.write file.FilePath&file.FileName&" ("&file.FileSize&") => "&formPath&File.FileName&" 成功!<br>"
iCount=iCount+1
end if
set file=nothing
next

set upload=nothing ''删除此对象
Htmend iCount&" 个文件上传结束!"

sub HtmEnd(Msg)
set upload=nothing
response.write "<br>"&Msg&" [<a href=""javascript:history.back();"">返回</a>]</body></html>"
response.end
end sub
%>
</body>
</html>

upload_5xsoft.inc
<SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT>
dim Data_5xsoft

Class upload_5xsoft

dim objForm,objFile,Version

Public function Form(strForm)
strForm=lcase(strForm)
if not objForm.exists(strForm) then
Form=""
else
Form=objForm(strForm)
end if
end function

Public function File(strFile)
strFile=lcase(strFile)
if not objFile.exists(strFile) then
set File=new FileInfo
else
set File=objFile(strFile)
end if
end function

Private 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="化境HTTP上传程序 Version 2.0"
set objForm=Server.CreateObject("Scripting.Dictionary")
set objFile=Server.CreateObject("Scripting.Dictionary")
if Request.TotalBytes<1 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) < iFormEnd
iInfoEnd = InStrB(iFormStart,RequestData,vbCrlf & vbCrlf)+3
tStream.Type = 1
tStream.Mode =3
tStream.Open
Data_5xsoft.Position = iFormStart
Data_5xsoft.CopyTo tStream,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))
'如果是文件
if InStr (45,sInfo,"filename=""",1) > 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 =nothing
End Sub

Private Sub Class_Terminate
if Request.TotalBytes>0 then
objForm.RemoveAll
objFile.RemoveAll
set objForm=nothing
set objFile=nothing
Data_5xsoft.Close
set Data_5xsoft =nothing
end if
End 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 function
End Class

Class 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("Adodb.Stream")
dr.Mode=3
dr.Type=1
dr.Open
Data_5xsoft.position=FileStart
Data_5xsoft.to dr,FileSize
dr.SaveToFile FullPath,2
dr.Close
set dr=nothing
SaveAs=false
end function
End Class
</SCRIPT>

5. asp.net如何实现上传文件到数据库并下载

网上有不少asp.net上传下载的代码,可以参考这里

http://pw.cnblogs.com/archive/2006/05/24/408427.html

主要的一句话在这里:

postedFile.SaveAs(phyPath+fileName);

文件是上传到服务器的,不是上传到数据库,至于文件路径,可以记录到数据库,也可以直接将链接写到下载点。

6. 怎样把从网上下下来的ASP代码上传到自己的网站上,又怎么用说的详细点儿,我是菜鸟。

把自己下载下来的代码文件放到一个文件夹里.文件夹里目录结构不要改.
然后用FTP连接你网站虚拟主机,直接把这个文件夹上传到你空间的目录里.
如果你原来网站域名是:www.abcd.com
那你这样就能访问你上传的代码了:www.abcd.com/上传文件夹名

如果说你不想要原来的代码,想用新的这个.那你先把原来空间的文件删除掉.然后把新的这个代码文件全部上传到空间的根目录下.记住,这次不是把所以的代码文件放到一个文件夹再上传.而是把把这个文件夹下面的N多个文件传到空间的根目录里...文件夹不要
不明白再Q我

7. asp建站如何实现上传和下载

最好是组件类上传下载,无组件的不太支持大文件和压缩类文件。
给你一个最简单的ASPUPLOAD(网上有下载的)组件上传代码。国内空间和服务器一般都支持ASPUPLOAD
只要你的网页form ACTION 到这个upload.asp 就上传了。先建一个upload目录
这个upload.asp 代码如下:
<%
Set Upload = Server.CreateObject("Persits.Upload") '重要的:驱动组件
HH_savepath=server.mappath("upload") '定义相对路径
Upload.Save(HH_savepath) '上传
%>
三句搞定,简单吧?哈哈

8. asp.net 2.0中如何实现上传文件与下载文件 用啥控件和代码啊

需用到FileUpLoad控件
#region 文件上传
/*
if (FileUpload1.HasFile)
{
string type = FileUpload1.PostedFile.ContentType.ToString();
if (type == "image/pjpeg")
{
string path = Server.MapPath("up/");
FileUpload1.PostedFile.SaveAs(path + FileUpload1.FileName);
Response.Write("<script>alert('上传成功!');</script>");
}
else
Response.Write("<script>alert('请上传获得支持的文件类型!');</script>");

}
else
Response.Write("<script>alert('请选择您要上传的文件!');</script>");
//*/

9. asp.net上传和下载的代码

太多了 一搜一大堆
ASP.NET上传和下载文件的代码
上传:(可以实现依次上传多个文件)

前台:

<%@ Register TagPrefix="ew1" Namespace="eWorld.UI" Assembly="eWorld.UI, Version=1.9.0.0, Culture=neutral, PublicKeyToken=24d65337282035f2" %>
<%@ Page language="c#" Codebehind="webNewBid.aspx.cs" AutoEventWireup="false" Inherits="STAR.Web.main.Bidding.WebNewBid" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebNewBid</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<LINK href="../../css/style.css" type="text/css" rel="stylesheet">
<script language="JavaScript">
function addFile()
{
var str = '<BR><INPUT type="file" size="50" NAME="File" runat="server">'
document.getElementById('MyFile').insertAdjacentHTML("beforeEnd",str)
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<table class="fullwidth" align="center">
<TR>
<TD vAlign="top">Attachment :</TD>
<TD>
<P id="MyFile"><input id="filMyFile" type="file" size="50" name="filMyFile"><input onclick="addFile()" type="button" value="Add"></P>
<asp:label id="lblAttachmentError" runat="server" ForeColor="Red"></asp:label><BR>
<asp:button id="btnUpload" runat="server" Text="Upload"></asp:button><asp:label id="lblAttachment" runat="server"></asp:label></TD>
</TR>
</table>
</form>
</body>
</HTML>

后台:

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Collections.Specialized;
private void btnUpload_Click(object sender, System.EventArgs e)
{
HttpFileCollection files = HttpContext.Current.Request.Files;
for(int i = 0; i < files.Count; i++)
{
if (i<files.Count&&i<10)
{
if (files[i].FileName!="" || files[i] != null)
{
int FileSize = 6*1024*1024;
HttpPostedFile myFile = files[i];
string strFilePath = myFile.FileName.ToString().Trim();
this.lblAttachmentError.Text = "<" + strFilePath + ">"; // Show file name
int nFindSlashPos = strFilePath.Trim().LastIndexOf("\\")+1;
string UploadFileName=strFilePath.Substring(nFindSlashPos);
string FileName=this.txtWorkOrder.Text+"_"+string.Format("{0:yyMMdd-hhmmss}",DateTime.Now)+"_"+UploadFileName;

if(myFile.FileName.Trim() == "") // Empty value in Browse Box
{
this.lblAttachmentError.Text="No file selected.";
return;
}

if(myFile.ContentLength != 0)
{
if (myFile.ContentLength > FileSize)
{
this.lblAttachmentError.Text="File Size is limited to 6 MB only.";
return;
}
this.lblAttachment.Text+= "<BR>"+FileName;
this.lblAttachmentError.Text="";
// string s=this.Request.PhysicalApplicationPath.ToString().Trim();
// string s1=this.Request.ApplicationPath.ToString().Trim();
// string s3=this.Server.MapPath("");
myFile.SaveAs(this.Request.PhysicalApplicationPath.ToString().Trim()+@"\uploads\" + FileName);
ArrayFileName[i]= FileName;
// // return;
}
else
{
this.lblAttachmentError.Text="File not found.";
return;
}
}
}
else
this.lblAttachmentError.Text="Uploaded File exceed limits.";
}
}

下载:(我只给了后太代码)

public bool ResponseFile(HttpRequest _Request, HttpResponse _Response, string _fileName, string _fullPath, long _speed)
{
try {
FileStream myFile = new FileStream(_fullPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
BinaryReader br = new BinaryReader(myFile);
try {
_Response.AddHeader("Accept-Ranges", "bytes");
_Response.Buffer = false;
long fileLength = myFile.Length;
long startBytes = 0;
Int16 pack = 10240;
Int16 sleep = Convert.ToInt16(Math.Floor(1000 * pack / _speed) + 1);
if (!(_Request.Headers("Range") == null)) {
_Response.StatusCode = 206;
char[] splitChar = new char[1];
splitChar(0) = "=";
splitChar(1) = "-";
string[][0] range = _Request.Headers("Range").Split("a");
startBytes = Convert.ToInt64(range(1));
}
_Response.AddHeader("Content-Length", (fileLength - startBytes).ToString());
if ((startBytes != 0)) {
_Response.AddHeader("Content-Range", string.Format(" bytes {0}-{1}/{2}", startBytes, fileLength - 1, fileLength));
}
_Response.AddHeader("Connection", "Keep-Alive");
_Response.ContentType = "application/octet-stream";
_Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(_fileName, System.Text.Encoding.UTF8));
br.BaseStream.Seek(startBytes, SeekOrigin.Begin);
long maxCount = Convert.ToInt64(Math.Floor((fileLength - startBytes) / pack) + 1);
long i;
for (int i = 0; i <= maxCount; i++) {
if ((_Response.IsClientConnected)) {
_Response.BinaryWrite(br.ReadBytes(pack));
Thread.Sleep(sleep);
} else {
i = maxCount;
}
}
} catch (Exception e) {
return false;
} finally {
br.Close();
myFile.Close();
}
} catch {
return false;
}
}

10. ASP上传文件代码

1、2可以解决,3有点复杂,我对无组件上传也不是很熟悉,很久没有碰过了,
建议你使用别人做好的上传类,像无惧上传类、稻香老农的化境asp无组件上传类等都可以,有很多,都挺好用的。

关于1、2的问题可参照下面的解决办法,因为你的代码全写在一行,读起来太麻烦,所以我给拆开了。代码如下:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>

<body>
<%
Response.Expires=0
if Request.TotalBytes then
set a=createobject("adodb.stream")
a.Type=1
a.Open
a.write Request.BinaryRead(Request.TotalBytes)
a.Position=0
b=a.Read
c=chrB(13)&chrB(10)
d=clng(instrb(b,c))
e=instrb(d+1,b,c)

set f=createobject("adodb.stream")
f.type=1
f.open
a.Position=d+1
a.to f,e-d-3
f.Position=0
f.type=2
f.CharSet="GB2312"
g=f.readtext
f.Close
h=mid(g,instrRev(g,"\")+1,e)
i=instrb(b,c&c)+4
j=instrb(i+1,b,leftB(b,d-1))-i-2
if j <1 then
set f =nothing
set a =nothing
response.write "未选择要上传的文件<a href='?'>重新上传</a>"
response.end
end if
f.Type=1
f.Open
a.Position=i-1
a.CopyTo f,j
f.SaveToFile server.mappath("/images/"& h),2 '上传至“/images/”文件夹中
f.Close
set f=Nothing
a.Close
set a=Nothing
response.write "<a href="&Server.URlEncode(h)&">"&h&"</a>"
end if
%>
<script language="javascript">
function checkupload(){
if(document.upload_form.fe.value ==""){
alert("未选择要上传的文件");
return false;
}
}
</script>
<form name="upload_form" enctype="multipart/form-data" method="post" onsubmit="return(checkupload())">
<input type="file" name="fe">
<input type="submit" value="上传" name="B1"></form>
</body>
</html>

热点内容
全排列递归算法java 发布:2025-09-20 08:25:00 浏览:415
如何在服务器里做算 发布:2025-09-20 08:12:33 浏览:1000
易游源码 发布:2025-09-20 08:12:18 浏览:460
qq密码破解器怎么用 发布:2025-09-20 08:10:58 浏览:250
代谢数据库 发布:2025-09-20 07:46:06 浏览:11
b612存储位置 发布:2025-09-20 07:37:56 浏览:619
党政网是什么服务器 发布:2025-09-20 07:33:35 浏览:8
网易邮箱上传插件 发布:2025-09-20 07:21:09 浏览:232
在哪里看自己设置的qq密码 发布:2025-09-20 07:18:54 浏览:332
lg电视密码如何解锁 发布:2025-09-20 06:51:34 浏览:870