无组件ASP文件上传源代码
记得在建立一个文件夹"updata"
saveannounce_upload.asp 上传页
------------------------------------
body {font-size:9pt;}
input {font-size:9pt;}
文件上传
文件
------------------------------------
saveannouce_upfile.asp 保存文件到服务器
------------------------------------
文件上传
<%
dim upload,file,formName,formPath
set upload=new upload_5xSoft ''建立上传对象
formPath=upload.form("filepath") ''在目录后加(/)
if right(formPath,1)"/" then formPath=formPath&"/"
for each formName in upload.file ''列出所有上传了的文件
set file=upload.file(formName) ''生成一个文件对象
if file.filesize<100 then
response.write "请先选择你要上传的文件 [ 重新上传 ]"
response.end
end if
if file.filesize>500*1000 then '设置上传文件大小为500K
response.write "文件大小超过了限制 500K [ 重新上传 ]"
response.end
end if
if file.FileSize>0 then ''如果 FileSize > 0 说明有文件数据
file.SaveAs Server.mappath("updata\"&file.FileName) ''保存文件
end if
set file=nothing
next
set upload=nothing
response.write "文件上传成功 [ 继续上传 ]"
%>
------------------------------------
upload.inc 建立upload对象
------------------------------------
dim upfile_5xSoft_Stream
Class upload_5xSoft
dim Form,File,Version
Private Sub Class_Initialize
dim iStart,iFileNameStart,iFileNameEnd,iEnd,vbEnter,iFormStart,iFormEnd,theFile
dim strDiv,mFormName,mFormValue,mFileName,mFileSize,mFilePath,iDivLen,mStr
Version=""
if Request.TotalBytes<1 then Exit