<!--#include file="conn.asp"-->
<!--#include FILE="upload_5xsoft.inc"-->
<%
pic1 = session("pic1")
if pic1 = "" or isnull(pic1) then pic1 = "||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"
pic1 = split(pic1,"|",-1)
rspic = ""
dim upload,file,formName,formPath,iCount,newsid
set upload=new upload_5xSoft ''建立上传对象
formPath="/upimg/"
dim i
i=1
Allow=cint(Session("AllowIMage"))
'for each formName in upload.file ''列出所有上传了的文件
for i=1 to Allow
set file = upload.file("file"&i) ''生成一个文件对象
if file.fileName<>"" then
if instr("gif,bmp,jpg,png",lcase(getFileExtName(file.fileName)))=0 then '在此添加许可上传的文件格式。
Response.Write "<script>alert('图片格式错误!请返回!');history.back();</script>"
response.end
else
if file.FileSize>0 and file.FileSize<512000 then ''如果 FileSize > 0 说明有文件数据
mapfilename = "Company-"&Session("CompanyID")&"-"&i&"."& getFileExtName(file.fileName)
file.SaveAs Server.mappath(formPath& mapfilename) ''保存文件
rspic = rspic & "|"&"upimg/"&mapfilename
else
Response.Write "<script>alert('图片太大(512K)!上传失败!请返回!');history.back();</script>"
response.end
end if
end if
else
rspic = rspic & "|"&pic1(i)
end if
set file=nothing
sql = "update Company set pic1='"&rspic&"' where CompanyID="& cint(Session("CompanyID"))
conn.execute sql
session("pic1")=empty
next
set upload=nothing ''删除此对象
'获得文件的后缀名
function getFileExtName(fileName)
dim pos
pos=instrrev(filename,".")
if pos>0 then
getFileExtName=mid(fileName,pos+1)
else
getFileExtName=""
end if
end function
Response.Write "<script>alert('图片上载成功!请查看活动信息!');location.replace('Upimage.asp?AllowImage="&Session("AllowImage")&"');</script>"
response.end
%>
參考答案:这不是风声无组件上传程序原码吗?呵呵
没错误,不过你要把里面的一些参数改成你自己需要的.
比较文件目录什么的/