通过ASP上传如何上传图片到指定文件夹中,以及传入数据库,我用的是ACCESS2000 请高手指点。 30
通过ASP上传如何上传图片到指定文件夹中,以及传入数据库,我用的是ACCESS2000请高手指点。给出具体代码,以及附属的说明,比如说传到的文件夹名称等等将另外加分。我的...
通过ASP上传如何上传图片到指定文件夹中,以及传入数据库,我用的是ACCESS2000
请高手指点。给出具体代码,以及附属的说明,比如说传到的文件夹名称等等
将另外加分。
我的QQ549233436 展开
请高手指点。给出具体代码,以及附属的说明,比如说传到的文件夹名称等等
将另外加分。
我的QQ549233436 展开
展开全部
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="SundyUpload.asp"-->
<!--#include file="inc/conn.asp"-->
<%
'此例子文档编码都是UTF-8,如果是其他编码的系统,请将编码转换为相应的编码,不然表单获取数据可能会乱码
Dim objUpload,opt
Dim xmlPath
Dim fileFormName,objFile,counter,fileExt
opt = request.QueryString("opt")
If opt = "Upload" Then
xmlPath = Server.MapPath(request.QueryString("xmlPath"))'将虚拟路径转换为实际路径
Set objUpload=new SundyUpload '建立上传对象
objUpload.UploadInit xmlPath,"gb2312"
counter = 1'表单数据
For Each fileFormName In objUpload.objFile
Set objFile=objUpload.objFile(fileFormName)
fileSize = objFile.FileSize
if filesize>100000 then
response.Write("<script>alert('请不要上传大于1M文件!');history.go(-1);</script>")
response.End()
end if
strTemp= objFile.FilePath
Response.Write strTemp
fileName = mid(strTemp,InStrRev(strTemp, "\")+1)
fileExt=lcase(right(filename,4))
if fileEXT<>".rar" then
response.write "<script>alert('文件格式不对,请用.rar 格式的文件');history.go(-1);</script>"
response.end
end if
Response.Write("上传成功:" & objUpload.Form("normalForm") & "<BR><BR>")'获取
'g0=
f0=replace(replace(replace(now(),":","")," ",""),"-","")&"."&g0
If fileSize > 0 Then
Response.Write("File Size:" & fileSize & "<BR>")
Response.Write("File Name:" & objFile.FilePath & "<BR>")
t=Split(filename,".")
t1=t(1)
filename=Replace(Replace(Replace(now,":","")," ",""),"-","")&"."&t1
' Response.Write("File Description:" & objUpload.Form("fileDesc" & counter) & "<BR><BR>")
objFile.SaveAs Server.MapPath(".") & "\upload\" & fileName
Response.Write "Save at: "&Server.MapPath(".") & "\upload\" & fileName & "<br><br>"
End If
counter = counter + 1
Next
End If
'为上载进度条数据文件(XML文件指定虚拟路径)
'最好是随机的,因为可能多个人同时上载,需要不同的进度数据
'这个路径需要在提交的时候传入上载组件中,以便在上载过程中更改进度数据
'客户端使用Javascript来读取此XML文件,显示进度
xmlPath = "upload/" & Timer & ".xml"
SQL="Select * from applylist where user_id="&session("username")&""
set rs=server.createobject("adodb.recordset")
rs.open SQL,conn,1,3
rs("sourcename")= fileName
rs.update
rs.close
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Sundy Upload Progress Bar Example</title>
<script language="javascript">
function chkFrm(){
var objFrm = document.frmUpload;
if (objFrm.file1.value=="" && objFrm.file2.value==""){
alert("请选择一个文件");
objFrm.file1.focus();
return false;
}
objFrm.action = "upload.asp?opt=Upload&xmlPath=<%=xmlPath%>";
startProgress('<%=xmlPath%>');//启动进度条
return true;
}
</script>
</head>
<body leftmargin="0px" topmargin="0xp" marginwidth="0">
<div >
<table height="450" background="css/pl.gif")><tr><td align="center" width="280">
<form name="frmUpload" method="post" action="upload.asp" enctype="multipart/form-data" onSubmit="return chkFrm()">
<br>
<input type="file" name="file1" size="15">
<input type="submit" name="btnSubmit" value="上传"/>
</form></td></tr></table>
</div>
</body>
</html>
这是部分代码,太长,不好发上去,联系我
<!--#include file="SundyUpload.asp"-->
<!--#include file="inc/conn.asp"-->
<%
'此例子文档编码都是UTF-8,如果是其他编码的系统,请将编码转换为相应的编码,不然表单获取数据可能会乱码
Dim objUpload,opt
Dim xmlPath
Dim fileFormName,objFile,counter,fileExt
opt = request.QueryString("opt")
If opt = "Upload" Then
xmlPath = Server.MapPath(request.QueryString("xmlPath"))'将虚拟路径转换为实际路径
Set objUpload=new SundyUpload '建立上传对象
objUpload.UploadInit xmlPath,"gb2312"
counter = 1'表单数据
For Each fileFormName In objUpload.objFile
Set objFile=objUpload.objFile(fileFormName)
fileSize = objFile.FileSize
if filesize>100000 then
response.Write("<script>alert('请不要上传大于1M文件!');history.go(-1);</script>")
response.End()
end if
strTemp= objFile.FilePath
Response.Write strTemp
fileName = mid(strTemp,InStrRev(strTemp, "\")+1)
fileExt=lcase(right(filename,4))
if fileEXT<>".rar" then
response.write "<script>alert('文件格式不对,请用.rar 格式的文件');history.go(-1);</script>"
response.end
end if
Response.Write("上传成功:" & objUpload.Form("normalForm") & "<BR><BR>")'获取
'g0=
f0=replace(replace(replace(now(),":","")," ",""),"-","")&"."&g0
If fileSize > 0 Then
Response.Write("File Size:" & fileSize & "<BR>")
Response.Write("File Name:" & objFile.FilePath & "<BR>")
t=Split(filename,".")
t1=t(1)
filename=Replace(Replace(Replace(now,":","")," ",""),"-","")&"."&t1
' Response.Write("File Description:" & objUpload.Form("fileDesc" & counter) & "<BR><BR>")
objFile.SaveAs Server.MapPath(".") & "\upload\" & fileName
Response.Write "Save at: "&Server.MapPath(".") & "\upload\" & fileName & "<br><br>"
End If
counter = counter + 1
Next
End If
'为上载进度条数据文件(XML文件指定虚拟路径)
'最好是随机的,因为可能多个人同时上载,需要不同的进度数据
'这个路径需要在提交的时候传入上载组件中,以便在上载过程中更改进度数据
'客户端使用Javascript来读取此XML文件,显示进度
xmlPath = "upload/" & Timer & ".xml"
SQL="Select * from applylist where user_id="&session("username")&""
set rs=server.createobject("adodb.recordset")
rs.open SQL,conn,1,3
rs("sourcename")= fileName
rs.update
rs.close
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Sundy Upload Progress Bar Example</title>
<script language="javascript">
function chkFrm(){
var objFrm = document.frmUpload;
if (objFrm.file1.value=="" && objFrm.file2.value==""){
alert("请选择一个文件");
objFrm.file1.focus();
return false;
}
objFrm.action = "upload.asp?opt=Upload&xmlPath=<%=xmlPath%>";
startProgress('<%=xmlPath%>');//启动进度条
return true;
}
</script>
</head>
<body leftmargin="0px" topmargin="0xp" marginwidth="0">
<div >
<table height="450" background="css/pl.gif")><tr><td align="center" width="280">
<form name="frmUpload" method="post" action="upload.asp" enctype="multipart/form-data" onSubmit="return chkFrm()">
<br>
<input type="file" name="file1" size="15">
<input type="submit" name="btnSubmit" value="上传"/>
</form></td></tr></table>
</div>
</body>
</html>
这是部分代码,太长,不好发上去,联系我
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询