问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

跪求asp uploadify asp!

发布网友 发布时间:2022-04-12 14:27

我来回答

3个回答

热心网友 时间:2022-04-12 15:56

'======================================

'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="0352照片专用上传程序 V1.0 by xmc125"
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)
theFile.FileExt=GetFileExt(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 GetFileExt(FullPath)
If FullPath <> "" Then
GetFileExt = mid(FullPath,InStrRev(FullPath, ".")+1)
Else
GetFileExt = ""
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,FileExt,FileType,FileStart
Private Sub Class_Initialize
FileName = ""
FilePath = ""
FileSize = 0
FileStart= 0
FormName = ""
FileType = ""
FileExt = ""
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.copyto dr,FileSize
dr.SaveToFile FullPath,2
dr.Close
set dr=nothing
SaveAs=false
end function
End Class
</SCRIPT>

'========================================================================

'upfile.htm

'作用:上传前台文件,可以自己修改代码。

'=============================================================================

<html>
<head>
<title>化境上传</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
td { font-size: 9pt}
a { color: #000000; text-decoration: none}
a:hover { text-decoration: underline}
.tx { height: 16px; width: 30px; border-color: black black #000000; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 1px; border-left-width: 0px; font-size: 9pt; background-color: #eeeeee; color: #0000FF}
.bt { font-size: 9pt; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; height: 16px; width: 80px; background-color: #eeeeee; cursor: hand}
.tx1 { height: 20px; width: 30px; font-size: 9pt; border: 1px solid; border-color: black black #000000; color: #0000FF}
-->
</style>
</head>

<body bgcolor="#FFFFFF" text="#000000">
<form name="form1" method="post" action="upfile.asp" enctype="multipart/form-data" >
<table border="1" cellspacing="0" cellpadding="0" bordercolorlight="#000000" bordercolordark="#CCCCCC" width="91" height="23">
<tr>
<td align="left" valign="middle" height="18" width="18"> </td>
<td bgcolor="#CCCCCC" align="left" valign="middle" height="18" width="67"> 文件上传</td>
</tr>
</table>
<br>
<input type="hidden" name="act" value="upload">
<br>
<table width="71%" border="1" cellspacing="0" cellpadding="5" align="center" bordercolordark="#CCCCCC" bordercolorlight="#000000">
<tr bgcolor="#CCCCCC">
<td height="22" align="left" valign="middle" bgcolor="#CCCCCC"> 化境编程界文件上传</td>
</tr>
<tr align="left" valign="middle" bgcolor="#eeeeee">
<td bgcolor="#eeeeee" height="92">
<script language="javascript">
function setid()
{
str='<br>';
if(!window.form1.upcount.value)
window.form1.upcount.value=1;
for(i=1;i<=window.form1.upcount.value;i++)
str+='文件'+i+':<input type="file" name="file'+i+'" style="width:400" class="tx1"><br><br>';
window.upid.innerHTML=str+'<br>';
}
</script>
<li> 需要上传的个数
<input type="text" name="upcount" class="tx" value="1">
<input type="button" name="Button" class="bt" onClick="setid();" value="· 设定 ·">
</li>

<br>
<br>
<li>上传到:
<input type="text" name="filepath" class="tx" style="width:350" value="">
</li>
</td>
</tr>
<tr align="center" valign="middle">
<td align="left" id="upid" height="122"> 文件1:
<input type="file" name="file1" style="width:400" class="tx1" value="">
</td>
</tr>
<tr align="center" valign="middle" bgcolor="#eeeeee">
<td bgcolor="#eeeeee" height="24">
<input type="submit" name="Submit" value="· 提交 ·" class="bt">
<input type="reset" name="Submit2" value="· 重执 ·" class="bt">
</td>
</tr>
</table>
</form>
</body>
</html>
<script language="javascript">

setid();
</script>

'=========================================================================

'upfile.asp

'上传文件的后台处理程序,将文件保存至指定位置,并将文件的信息写入数据库。

'===========================================================================

<%OPTION EXPLICIT%>
<%Server.ScriptTimeOut=5000%>
<!--#include FILE="upload_5xsoft.inc"-->
<!--#include file="../inc/conn.asp"-->
<html>
<head>
<title>文件上传</title>
</head>
<body>
<br>文件上传!<hr size=1 noshadow width=300 align=left><br><br>
<%

dim upload,file,formName,formPath,iCount
'===================================================
'以下是自己添加的代码
'===================================================
dim maxfilesiz,fileEXT,upfiletype,EnableUpload,maxfilesize,Forumupload,msg
'upfiletype="gif|jpg|bmp|png|swf|doc|xls|pdf|rar|zip|avi|mpg|mp3|mp4|VOB" '允许上传的文件类型
upfiletype="gif|jpg"
maxfilesize=5*1024*1024 '允许上传文件大小不超过5M
'===================================================
set upload=new upload_5xsoft ''建立上传对象

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

'====================================================

'以下代码是源文件的代码,全部注释掉。根据需要做了修改
'=====================================================
dim bigclass
if upload.form("filepath")="" then ''得到上传目录
HtmEnd "请输入要上传至的目录!"
set upload=nothing
response.end
else
bigclass=upload.form("filepath")
''在目录后加(/)
'if right(formPath,1)<>"/" then formPath=formPath&"/"
end if
'======================================================
formPath="/0352/upload/" '自己修改保存路径

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) ''生成一个文件对象

'=====================================================================
fileExt=lcase(file.FileExt)
Forumupload=split(upfiletype,"|")
EnableUpload=false
dim i
for i=0 to ubound(Forumupload)
if fileEXT=trim(Forumupload(i)) then
EnableUpload=true
exit for
end if
next
if fileEXT="asp" or fileEXT="asa" or fileEXT="aspx" then
EnableUpload=false
end if
if EnableUpload=false then

msg="这种文件类型不允许上传!\n\n只允许上传这几种文件类型:" & UpFileType
'founderr=true
end if
'===========================================================================

if file.FileSize>0 and EnableUpload=true then ''如果 FileSize > 0 说明有文件数据
dim ranNum
ranNum=int(900*rnd)+100
dim savepath,filename
savepath=formpath
filename=SavePath&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&"."&fileExt
file.SaveAs Server.mappath(FileName) '保存文件
'file.Saveas Server.mappath(formPath&file.FileName)
response.write file.FilePath&file.FileName&" ("&file.FileSize\1024&" KB) => "&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>

'==========================================================================

有不懂的地方可以问我

热心网友 时间:2022-04-12 17:14

这个asp能用吗?
怎么不用aspupload?
----------------------
简单的看了一下,不错,研究下给你结果。
----------------------
因为在uploadify.php中存在的变量是由uploadify.swf来生成的。因此这东西不能在asp中使用。

除非有人能修改uploadify.swf,下载中给出了uploadify.swf的源码,而我不熟悉php,更不熟悉flash,因此无法帮你搞定。

热心网友 时间:2022-04-12 18:49

艾恩多文件上传,看看
声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
历史要怎么读,有啥诀窍 高中历史诀窍 年终会活动策划方案 深度解析:第一财经回放,探索财经新风向 逆水寒手游庄园怎么邀请好友同住 逆水寒手游 逆水寒不同区可以一起组队吗? 逆水寒手游 逆水寒怎么进入好友世界? 逆水寒手游 逆水寒怎么去别人的庄园? 使用puppeteer实现将htmll转成pdf 内卷时代下的前端技术-使用JavaScript在浏览器中生成PDF文档 手中有2个*ST股票,后市如何操作啊.. 手机有无边框的必要吗? TOMOFREE电动车限速怎么解 tomofree电动车中文是什么 tomofree属于啥档次 tomofree是德国品牌吗 什么是无边框手机 tomofree电动车是杂牌么 最新无边框手机哪款好 校园生活一件事 作文 550字左右 真正的无边框手机是什么牌子? 无边框手机能否成为未来手机新主流? 大神们,手机屏幕要做到无边框很难吗 关于难忘的校园生活的作文 无边框手机有哪些 手机无边框设计有哪些缺点? uploadify批量上传?? 弘缠院缠豆怎么赚 52投资缠论李晓军用什么炒股软件 缠中说禅逐句讲解,的缠论中是什么编写软件? php+uploadify文件不能上传问题,急急! 拍高速上应急车道的车怎么上传给交警 有走应急车道照片如何上报 有车辆走应急车道我拍照发网上可以吗 拍了应急车道上传哪里给钱 高速上拿手机拍到私家车在应急车道上行驶的照片怎么发给交警? 应急车道拍照怎么处罚? 想用电饭煲焖鸡 不会糊吗 懒人美食电饭煲焖鸡用什么方法做出来会非常的美味呢? 什么是限额以上工业增加值 限上大个体是什么标准 我国一般大中型和限额以上的项目通常经历哪些阶段 限上工业增加值是什么意思,怎么计算的 楞严咒唱诵 楞严经多少字?诵完一遍需要多长时间? 楞严心咒正确读音什么时间读诵楞严咒 南京实施“四新”行动计划 关于《楞严经》正确的颂读方式。 有什么软件可以扫描图片里的衣服给自己找一些好看的衣服? 怎样找到网上图片里的衣服