導航:首頁 > 文件教程 > asp多文件無組件上傳

asp多文件無組件上傳

發布時間:2023-05-05 06:33:55

『壹』 怎樣設置ASP無組件上傳文件的類型

for each formName in upload.file ''列出所有上傳了的文件
set file=upload.file(formName) ''生成一個文件對象
if file.FileSize>0 then ''如果 FileSize >虛睜猛 0 說明有文件數據

if lcase(file.FileExt)="jpg" then '簡單一個示例

file.SaveAs Server.mappath(formPath&file.FileName) ''保存差橋文件
response.write file.FilePath&file.FileName&"上傳至伺服器文件夾 "&formPath&" 位置早冊【成功】<br>"
end if
iCount=iCount+1
end if
set file=nothing
next

『貳』 化境ASP無組件類上傳大文件的問題

如果不能上傳大文件的話,那就是伺服器2003系統上的設置問態緩題了.

解決辦法:

1. 關閉 IIS Admin Service 服務 (運帆輪模行iisreset.exe /stop)

2. 打開桐消 Windows\system32\inesrv\metabase.xml

3. 修改 SPMaxRequestEntityAllowed 的值為自己需要的, 默認為 204800

4. 啟動 IIS Admin Service (運行iisreset.exe /start)

注意備份metabase.xml 文件

『叄』 急求:ASP無組件多圖片上傳組件 上傳的文件名不要重復

這個簡單
<%
Set myRequest=new UpLoadClass
myRequest.FileType ="gif/jpg"'"gif/jpg"
myRequest.Savepath = "pic/"
myrequest.open

sql = "select * from tab"兆指
set rs = server.createobject("adodb.recordset")
rs.open sql,conn,1,3
rs.addNew
rs("title") = myRequest.Form("title")
rs("file1") = myRequest.Form("file1")
rs("file2") = myRequest.Form("file2")
rs.update
set rs = nothing
%>
1.文件自動上傳到pic目錄自按日期時間生成不重復的文件名
2.上傳的文件的文件洞卜名自動生成並可這樣取出
myRequest.Form("file1")
3.text框的數據這樣取
myRequest.Form("title")
4.這個類納猜穗的代碼可在這里
<%
'*****************************圖片上傳類開始*******************
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 = 204800000000'0//設定上傳圖片大小
p_FileType = "jpg/gif"
p_SavePath = ""
p_AutoSave = 0
strDate = replace(cstr(Date()),"-","")
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 Function

End Class

%>

『肆』 ASP怎樣無組件上傳文件到指定文件夾,並且將路徑寫入資料庫如題 謝謝了

<head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>示例結果</title> <link href="../style.css" rel="stylesheet" type="text/css"> </head> <body style="font-size:12px"> <% Dim Upload,successful '=============================================================================== set Upload=new AnUpload '創建類實例 Upload.SingleSize=1024*1024 '設置單個文件最大上傳限制,按位元組計;默認為不限制 Upload.MaxSize=4096*1024 '設置最大上傳限制,按位元組計;默認為不限制 Upload.Exe="rar|jpg|bmp|gif|doc|xls|ppt|txt" '設置合法擴展名,以|分割,忽略大小寫 Upload.GetData() '獲取並保存數據,必須調用本方法 '=============================================================================== if Upload.Err>0 then '判斷錯誤號,如果myupload.Err<=0表示正常 response.write Upload.Description '如果出現錯誤,獲取錯誤描述 else response.Write "表單text1的值為: " & Upload.Forms("text1") & "<br />" if Upload.forms("file1")<>"" then '這里判斷你file1是否選擇了文件 path=server.mappath("files") '文件保存路徑(這里是files文件夾) set tempCls=Upload.files("file1") successful=tempCls.SaveToFile(path,0) '以時間+隨機數字為文件名保存 'successful=tempCls.SaveToFile(path,1) '如果想以原文件名保存,請使用本句 if successful then response.write tempCls.FileName & "上傳完畢,大小為" & Upload.getsize(tempCls.Size) & ";<br />本地路徑" & Upload.forms("file1") & "!<br />" Response.Redirect "InsertDatabase.asp?FileName="&Upload.Forms("text1")&"&FilePath="&tempCls.FileName else response.write "上傳失敗" end if set tempCls=nothing end if end if set Upload=nothing '銷毀類實例 %> </body> </html>
採納哦

『伍』 asp無組件上傳

<!-- #include file="public.asp" -->
<%
Head
CheckAdminPower powernum
TopName "信 息 發 布 中 心"
Operation 0,0,0,""
InfoNav
%>
<%
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>
<style type="text/css">
<!--
body,input {font-size:12px;}
-->
</style>
<title>文件上傳</title>
</head>
<body id="body">
<%
ExtName = "jpg,gif,png,txt,rar,zip,doc" '允許擴展名
SavePath = "../../cn/upload" '保存路徑
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 = "utf-8"
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=Nothing
End Function
%>

『陸』 ASP 無組件上傳用法

正常的兆族話,下載的程序,都有demo演示的,如果沒有,其實這個也簡單,就幾個文並桐件一個上傳入口,其餘幾個都是上傳組件的類文件,之需要在你需要添加上傳表單域的代碼位置直接引入上傳入口文件即可。使用<!--#include file="uploadfile.asp"-->類似的,此族蔽弊處文件為你的上傳入口文件。============================如有問題不懂,請加QQ 591350137

『柒』 asp 無組件上傳

找大畝擾到 Forum_upload ="jpg,rar," '用滾旦逗號分隔,然後你就往裡加允許文件類型的後綴名吧
LS的 uploadsuc 不是

用Dreamweaver整站查找。。。耐咐。肯定有

『捌』 關於用asp無組件上傳文件遇到的問題,求助!!!

asp上傳文件以二進制方式存儲在資料庫中,應該是沒有問題的,但問題是打開上傳文如橋亮件根據文件類型不同打開的方消檔式是不一樣的,txt文件可以用文本方式打開,但word文件必須使用word軟體打開,不能使用文本方式打開。因此在存儲時必須有文件的擴展名,根據擴展名不同使用不渣寬同的打開方式。

『玖』 ASP無組件上傳

2個文件
第一個文件:
<html>
<body>
<center>
<form name="mainForm" enctype="multipart/form-data" action="process.asp" method=post>
<input type=file name=mefile><br>
<input type=submit name=okvalue="OK">
</form>
</center>
</body>
</html>

第二個:
<%
sub pic()
if Request.QueryString("submit")="pic" then
uploadpath="image/face/"
uploadsize="2048"
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.form2.pic.value='"&Uprequest.SavePath&Uprequest.Form("file")&"';"
response.write "</script>"
response.write "</script>"
size=Uprequest.Form("file_size")
showsize=size & " Byte"
if size>1024 then
size=(size\1024)
showsize=size & " KB"
end if
if size>1024 then
size=(size/1024)
showsize=formatnumber(size,2) & " MB"
end if
response.write "<script language=""javascript"">parent.form2.url.value='"&showsize&"';"
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 if
Set Uprequest=nothing
end if
response.write "<form name=form action=?action=pic&submit=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>"
end sub
%>

閱讀全文

與asp多文件無組件上傳相關的資料

熱點內容
win10刪除c盤文件會刪掉系統嗎 瀏覽:785
qq的獨立密碼怎麼取消 瀏覽:289
後台的商品數據在哪裡看 瀏覽:795
不用網路載入的單機游戲有哪些 瀏覽:608
數據線插頭怎麼接頭 瀏覽:577
網路載入視頻失敗是怎麼回事 瀏覽:805
傳奇賬號在哪個文件夾里 瀏覽:346
百度app在哪裡安裝 瀏覽:587
如何設置路由器網路不斷網 瀏覽:471
傳到qq群里的文件怎麼刪除 瀏覽:861
索尼安卓71更新日誌 瀏覽:234
怎麼找手機里的垃圾app 瀏覽:540
2015藍橋杯代碼填空 瀏覽:698
安卓資料庫dbexecSQL 瀏覽:227
doc重命名文件格式 瀏覽:728
getscreen截圖工具下載 瀏覽:719
共識數據是什麼時候開始的 瀏覽:96
數碼管顯示電壓程序 瀏覽:479
資料庫文件有哪個 瀏覽:543
途強儲存在哪個文件夾 瀏覽:172

友情鏈接