asp+javascript无组件上传
asp+javascript无组件上传的方法,建议,源代码最好!!
------解决方案--------------------二个文件:一个是upload.asp,用于嵌套到你需的要asp文件,记录加一个参数:pic=你需要填充上传文件路径的控件名,源码如下:
<html>
<head>
<%
dim pic
pic=request.QueryString( "pic ")
%>
<%if request.QueryString( "photourl ") <> " " then%>
<script>
if(opener.form1. <%=pic%> .value== " ")
{
opener.form1. <%=pic%> .value+= "file/ <%=request.QueryString( "photourl ")%> ";
}
else
{
opener.form1. <%=pic%> .value= "file/ <%=request.QueryString( "photourl ")%> ";
}
window.close();
</script>
<%end if%>
<title> 文件上传 </title>
</head>
<body background=image/bg.gif>
<table width= "100% " border= "0 " cellspacing= "0 " cellpadding= "0 ">
<tr>
<td align= "center "> 上传图片 </td>
</tr>
</table>
<form action= "upload_check.asp?pic= <%=pic%> " method= "post " enctype= "multipart/form-data ">
<table cellPadding=0 cellSpacing=0 border=0 width=100% align= "center ">
<tr>
<td width= "70% " align= "right ">
<input type=file name=file1 style= "border:1px solid #808000; width:180;height:22;background-color=#FFFFFF " size= "20 "> </td>
<td width= "30% " align= "left "> <input type=submit value= "上传... " style= "border:1px solid #808000; background-color=#EBE9ED;width=50;height:19 ">
<td>
</tr>
</table>
</form>
</body>
</html>
另一个是用于上传文件的asp文件:upload_check.asp,源码如下:
<%
dim pic
pic=request.QueryString( "pic ")
Function BtoS (bstr)
If bstr <> " " Then
for i = 0 to lenb(bstr) - 1
bchr = midb(bstr,i+1,1)
temp = temp&chr(ascb(bchr))
next
End If
BtoS = temp
End Function
formsize=request.totalbytes
if formsize <> 0 and session( "username ") = " " then
formdata=request.binaryread(formsize)
bncrlf=chrB(13) & chrB(10)
divider=leftB(formdata,clng(instrb(formdata,bncrlf))-1)
ender=bncrlf & divider & chrB(45) & chrB(45)
bodyjpg=midb(formdata,instrb(formdata,bncrlf&bncrlf)+lenb(bncrlf&bncrlf),instrb(formdata,ender)-instrb(formdata,bncrlf&bncrlf)-lenb(bncrlf&bncrlf))
if lenb(bodyjpg) <=20485760 then
Typeis=chrb(084)&chrb(121)&chrb(112)&chrb(101)&chrb(058)&chrb(032)
Typepath=midb(formdata,instrb(formdata,Typeis)+lenb(Typeis),instrb(instrb(formdata,Typeis)+lenb(Typeis),formdata,bncrlf)-instrb(formdata,Typeis)-lenb(Typeis))
ContenType=BtoS(Typepath)
if ContenType= "application/msword " then
photos= "1 "
filename3= "doc "
elseif ContenType= "application/vnd.ms-excel " then
photos= "1 "
filename3= "xls "
elseif ContenType= "application/octet-stream " then
photos= "1 "
filename3= "rar "
elseif ContenType= "application/x-zip-compressed " then
photos= "1 "
filen