ASP 缺少标识符 错误 急
显示是:行:16字符:26错误:缺少标识符代码:0上传图片时出现的错误代码如下<styletype="text/css"><!--body{FONT-SIZE:9pt;c...
显示是:
行:16
字符:26
错误:缺少标识符
代码:0
上传图片时出现的错误
代码如下
<style type="text/css">
<!--
body {
FONT-SIZE: 9pt; color:#FF0000;
background-color: #f0f0f0;
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
.bt1 { font-size: 9pt; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; height: 16px; width: 60px; background-color:#ffffff; cursor: hand}
-->
</style><%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%server.scripttimeout=9999%>
<!-- #include file="upload.inc" -->
<script>parent.document.form.Submit.disabled=false;</script>
<%
call upload_0()
sub upload_0()
dim upload,file,fpath,filename,fileext
set upload=new UpFile_Class '建立对像
n=5120
sizes=n*1024
'300kb大小
upload.getdate(sizes)
if upload.err>0 then
select case upload.err
case 1
Response.Write "请先选择你要上传的文件 [ <a href=# onclick=history.go(-1)>重新上传</a> ]"
case 2
Response.Write "文件大小超过了限制 "&n&"K [ <a href=# onclick=history.go(-1)>重新上传</a> ]"
end select
exit sub
else
fpath=upload.form("filepath")
if right(fpath,1)<>"/" then fpath=fpath&"/"
for each formname in upload.file '列出上传的文件
set file=upload.file(formname) '生成文件对象
fileext=lcase(file.fileExt)
if fileext="asp" or fileext="aspx" or fileext="asa" then
checkfileext(fileext)=false
end if
if checkfileext(fileext)=false then
response.write "格式不正确 <a href=# onclick=history.go(-1)>重新上传</a>"
response.end
end if
filesize=file.filesize
Sizes=formatnumber(file.filesize/1024,0)&"KB"
randomize
newname=year(now())&month(now())&day(now)&hour(now())&minute(now())&second(now())&left(clng((10000-1000+1)*rnd+1),4)
filename=newname&"."&file.fileExt
names=filename
filename=fpath&filename
if filesize>0 then
file.SaveToFile server.mappath(filename)
pic=upload.form("pic")
response.write "<script>parent.document.forms[0]."&upload.form("tup")&".value='"&names&"'</script>"
response.write "<script>parent.document.forms[0]."&upload.form("tup2")&".value='"&Sizes&"'</script>"
response.write "上传文件成功"
'response.end
end if
set file=nothing
next
end if
end sub
function checkfileext(fileext)
fileext=replace(lcase(fileext),".",",")
filepic=".gif.jpg.png.bmp.jpeg.rar.zip.exe.doc.xls.chm.hlp.pdf.swf"
filepic2=split(filepic,".")
for i=0 to ubound(filepic2)
if fileext=trim(filepic2(i)) then
checkfileext=true
exit function
else
checkfileext=false
end if
next
end function
%>
谢谢楼上先
upload.inc文件代码如下:
<%
Dim oUpFileStream,FormData
Class UpFile_Class
Dim Form,File,Version,Err
Private Sub Class_Initialize
Version = "上传类 Version V1.0"
Err = -1
End Sub
Private Sub Class_Terminate
'清除变量及对像
If Err < 0 Then
Form.RemoveAll
Set Form = Nothing
File.RemoveAll
Set File = Nothing
oUpFileStream.Close
Set oUpFileStream = Nothing
End If
End Sub
Public Sub GetDate (RetSize)
'定义变量
Dim RequestBinDate,sSpace,bCrLf,sInfo,iInfoStart,iInfoEnd,tStream,iStart,oFileInfo
Dim iFileSize,sFilePath,sFileType,sFormValue,sFileName
Dim iFindStart,iFindEnd
Dim iFormStart,iFormEnd,sFormName 展开
行:16
字符:26
错误:缺少标识符
代码:0
上传图片时出现的错误
代码如下
<style type="text/css">
<!--
body {
FONT-SIZE: 9pt; color:#FF0000;
background-color: #f0f0f0;
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
.bt1 { font-size: 9pt; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; height: 16px; width: 60px; background-color:#ffffff; cursor: hand}
-->
</style><%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%server.scripttimeout=9999%>
<!-- #include file="upload.inc" -->
<script>parent.document.form.Submit.disabled=false;</script>
<%
call upload_0()
sub upload_0()
dim upload,file,fpath,filename,fileext
set upload=new UpFile_Class '建立对像
n=5120
sizes=n*1024
'300kb大小
upload.getdate(sizes)
if upload.err>0 then
select case upload.err
case 1
Response.Write "请先选择你要上传的文件 [ <a href=# onclick=history.go(-1)>重新上传</a> ]"
case 2
Response.Write "文件大小超过了限制 "&n&"K [ <a href=# onclick=history.go(-1)>重新上传</a> ]"
end select
exit sub
else
fpath=upload.form("filepath")
if right(fpath,1)<>"/" then fpath=fpath&"/"
for each formname in upload.file '列出上传的文件
set file=upload.file(formname) '生成文件对象
fileext=lcase(file.fileExt)
if fileext="asp" or fileext="aspx" or fileext="asa" then
checkfileext(fileext)=false
end if
if checkfileext(fileext)=false then
response.write "格式不正确 <a href=# onclick=history.go(-1)>重新上传</a>"
response.end
end if
filesize=file.filesize
Sizes=formatnumber(file.filesize/1024,0)&"KB"
randomize
newname=year(now())&month(now())&day(now)&hour(now())&minute(now())&second(now())&left(clng((10000-1000+1)*rnd+1),4)
filename=newname&"."&file.fileExt
names=filename
filename=fpath&filename
if filesize>0 then
file.SaveToFile server.mappath(filename)
pic=upload.form("pic")
response.write "<script>parent.document.forms[0]."&upload.form("tup")&".value='"&names&"'</script>"
response.write "<script>parent.document.forms[0]."&upload.form("tup2")&".value='"&Sizes&"'</script>"
response.write "上传文件成功"
'response.end
end if
set file=nothing
next
end if
end sub
function checkfileext(fileext)
fileext=replace(lcase(fileext),".",",")
filepic=".gif.jpg.png.bmp.jpeg.rar.zip.exe.doc.xls.chm.hlp.pdf.swf"
filepic2=split(filepic,".")
for i=0 to ubound(filepic2)
if fileext=trim(filepic2(i)) then
checkfileext=true
exit function
else
checkfileext=false
end if
next
end function
%>
谢谢楼上先
upload.inc文件代码如下:
<%
Dim oUpFileStream,FormData
Class UpFile_Class
Dim Form,File,Version,Err
Private Sub Class_Initialize
Version = "上传类 Version V1.0"
Err = -1
End Sub
Private Sub Class_Terminate
'清除变量及对像
If Err < 0 Then
Form.RemoveAll
Set Form = Nothing
File.RemoveAll
Set File = Nothing
oUpFileStream.Close
Set oUpFileStream = Nothing
End If
End Sub
Public Sub GetDate (RetSize)
'定义变量
Dim RequestBinDate,sSpace,bCrLf,sInfo,iInfoStart,iInfoEnd,tStream,iStart,oFileInfo
Dim iFileSize,sFilePath,sFileType,sFormValue,sFileName
Dim iFindStart,iFindEnd
Dim iFormStart,iFormEnd,sFormName 展开
2个回答
展开全部
谢谢楼上先
upload.inc文件代码如下:
<%
Dim oUpFileStream,FormData
Class UpFile_Class
Dim Form,File,Version,Err
Private Sub Class_Initialize
Version = "上传类 Version V1.0"
Err = -1
End Sub
Private Sub Class_Terminate
'清除变量及对像
If Err < 0 Then
Form.RemoveAll
Set Form = Nothing
File.RemoveAll
Set File = Nothing
oUpFileStream.Close
Set oUpFileStream = Nothing
End If
End Sub
Public Sub GetDate (RetSize)
'定义变量
Dim RequestBinDate,sSpace,bCrLf,sInfo,iInfoStart,iInfoEnd,tStream,iStart,oFileInfo
Dim iFileSize,sFilePath,sFileType,sFormValue,sFileName
Dim iFindStart,iFindEnd
Dim iFormStart,iFormEnd,sFormName
'代码开始
If Request.TotalBytes < 1 Then
Err = 1
Exit Sub
End If
If RetSize > 0 Then
If Request.TotalBytes > RetSize Then
Err = 2
Exit Sub
End If
End If
FormData = Request.BinaryRead(Request.TotalBytes)
Set Form = Server.CreateObject ("Scripting.Dictionary")
Form.CompareMode = 1
Set File = Server.CreateObject ("Scripting.Dictionary")
File.CompareMode = 1
Set tStream = Server.CreateObject ("ADODB.Stream")
Set oUpFileStream = Server.CreateObject ("ADODB.Stream")
oUpFileStream.Type = 1
oUpFileStream.Mode = 3
oUpFileStream.Open
oUpFileStream.Write FormData
oUpFileStream.Position = 0
RequestBinDate = oUpFileStream.Read
iFormEnd = oUpFileStream.Size
bCrLf = ChrB (13) & ChrB (10)
'取得每个项目之间的分隔符
sSpace = MidB (RequestBinDate,1, InStrB (1,RequestBinDate,bCrLf)-1)
iStart = LenB (sSpace)
iFormStart = iStart+2
'分解项目
Do
iInfoEnd = InStrB (iFormStart,RequestBinDate,bCrLf & bCrLf)+3
tStream.Type = 1
tStream.Mode = 3
tStream.Open
oUpFileStream.Position = iFormStart
oUpFileStream.CopyTo tStream,iInfoEnd-iFormStart
tStream.Position = 0
tStream.Type = 2
tStream.CharSet = "gb2312"
sInfo = tStream.ReadText
'取得表单项目名称
iFormStart = InStrB (iInfoEnd,RequestBinDate,sSpace)-1
iFindStart = InStr (22,sInfo,"name=""",1)+6
iFindEnd = InStr (iFindStart,sInfo,"""",1)
sFormName = Mid (sinfo,iFindStart,iFindEnd-iFindStart)
'如果是文件
If InStr (45,sInfo,"filename=""",1) > 0 Then
Set oFileInfo = new FileInfo_Class
'取得文件属性
iFindStart = InStr (iFindEnd,sInfo,"filename=""",1)+10
iFindEnd = InStr (iFindStart,sInfo,"""",1)
sFileName = Mid (sinfo,iFindStart,iFindEnd-iFindStart)
oFileInfo.FileName = Mid (sFileName,InStrRev (sFileName, "\")+1)
oFileInfo.FilePath = Left (sFileName,InStrRev (sFileName, "\")+1)
oFileInfo.FileExt = Mid (sFileName,InStrRev (sFileName, ".")+1)
iFindStart = InStr (iFindEnd,sInfo,"Content-Type: ",1)+14
iFindEnd = InStr (iFindStart,sInfo,vbCr)
oFileInfo.FileType = Mid (sinfo,iFindStart,iFindEnd-iFindStart)
oFileInfo.FileStart = iInfoEnd
oFileInfo.FileSize = iFormStart -iInfoEnd -2
oFileInfo.FormName = sFormName
file.add sFormName,oFileInfo
else
'如果是表单项目
tStream.Close
tStream.Type = 1
tStream.Mode = 3
tStream.Open
oUpFileStream.Position = iInfoEnd
oUpFileStream.CopyTo tStream,iFormStart-iInfoEnd-2
tStream.Position = 0
tStream.Type = 2
tStream.CharSet = "gb2312"
sFormValue = tStream.ReadText
If Form.Exists (sFormName) Then
Form (sFormName) = Form (sFormName) & ", " & sFormValue
else
form.Add sFormName,sFormValue
End If
End If
tStream.Close
iFormStart = iFormStart+iStart+2
'如果到文件尾了就退出
Loop Until (iFormStart+2) = iFormEnd
RequestBinDate = ""
Set tStream = Nothing
End Sub
End Class
'文件属性类
Class FileInfo_Class
Dim FormName,FileName,FilePath,FileSize,FileType,FileStart,FileExt
'保存文件方法
Public Function SaveToFile (Path)
On Error Resume Next
Dim oFileStream
Set oFileStream = CreateObject ("ADODB.Stream")
oFileStream.Type = 1
oFileStream.Mode = 3
oFileStream.Open
oUpFileStream.Position = FileStart
oUpFileStream.CopyTo oFileStream,FileSize
oFileStream.SaveToFile Path,2
oFileStream.Close
Set oFileStream = Nothing
End Function
'取得文件数据
Public Function FileDate
oUpFileStream.Position = FileStart
FileDate = oUpFileStream.Read (FileSize)
End Function
End Class
%>
upload.inc文件代码如下:
<%
Dim oUpFileStream,FormData
Class UpFile_Class
Dim Form,File,Version,Err
Private Sub Class_Initialize
Version = "上传类 Version V1.0"
Err = -1
End Sub
Private Sub Class_Terminate
'清除变量及对像
If Err < 0 Then
Form.RemoveAll
Set Form = Nothing
File.RemoveAll
Set File = Nothing
oUpFileStream.Close
Set oUpFileStream = Nothing
End If
End Sub
Public Sub GetDate (RetSize)
'定义变量
Dim RequestBinDate,sSpace,bCrLf,sInfo,iInfoStart,iInfoEnd,tStream,iStart,oFileInfo
Dim iFileSize,sFilePath,sFileType,sFormValue,sFileName
Dim iFindStart,iFindEnd
Dim iFormStart,iFormEnd,sFormName
'代码开始
If Request.TotalBytes < 1 Then
Err = 1
Exit Sub
End If
If RetSize > 0 Then
If Request.TotalBytes > RetSize Then
Err = 2
Exit Sub
End If
End If
FormData = Request.BinaryRead(Request.TotalBytes)
Set Form = Server.CreateObject ("Scripting.Dictionary")
Form.CompareMode = 1
Set File = Server.CreateObject ("Scripting.Dictionary")
File.CompareMode = 1
Set tStream = Server.CreateObject ("ADODB.Stream")
Set oUpFileStream = Server.CreateObject ("ADODB.Stream")
oUpFileStream.Type = 1
oUpFileStream.Mode = 3
oUpFileStream.Open
oUpFileStream.Write FormData
oUpFileStream.Position = 0
RequestBinDate = oUpFileStream.Read
iFormEnd = oUpFileStream.Size
bCrLf = ChrB (13) & ChrB (10)
'取得每个项目之间的分隔符
sSpace = MidB (RequestBinDate,1, InStrB (1,RequestBinDate,bCrLf)-1)
iStart = LenB (sSpace)
iFormStart = iStart+2
'分解项目
Do
iInfoEnd = InStrB (iFormStart,RequestBinDate,bCrLf & bCrLf)+3
tStream.Type = 1
tStream.Mode = 3
tStream.Open
oUpFileStream.Position = iFormStart
oUpFileStream.CopyTo tStream,iInfoEnd-iFormStart
tStream.Position = 0
tStream.Type = 2
tStream.CharSet = "gb2312"
sInfo = tStream.ReadText
'取得表单项目名称
iFormStart = InStrB (iInfoEnd,RequestBinDate,sSpace)-1
iFindStart = InStr (22,sInfo,"name=""",1)+6
iFindEnd = InStr (iFindStart,sInfo,"""",1)
sFormName = Mid (sinfo,iFindStart,iFindEnd-iFindStart)
'如果是文件
If InStr (45,sInfo,"filename=""",1) > 0 Then
Set oFileInfo = new FileInfo_Class
'取得文件属性
iFindStart = InStr (iFindEnd,sInfo,"filename=""",1)+10
iFindEnd = InStr (iFindStart,sInfo,"""",1)
sFileName = Mid (sinfo,iFindStart,iFindEnd-iFindStart)
oFileInfo.FileName = Mid (sFileName,InStrRev (sFileName, "\")+1)
oFileInfo.FilePath = Left (sFileName,InStrRev (sFileName, "\")+1)
oFileInfo.FileExt = Mid (sFileName,InStrRev (sFileName, ".")+1)
iFindStart = InStr (iFindEnd,sInfo,"Content-Type: ",1)+14
iFindEnd = InStr (iFindStart,sInfo,vbCr)
oFileInfo.FileType = Mid (sinfo,iFindStart,iFindEnd-iFindStart)
oFileInfo.FileStart = iInfoEnd
oFileInfo.FileSize = iFormStart -iInfoEnd -2
oFileInfo.FormName = sFormName
file.add sFormName,oFileInfo
else
'如果是表单项目
tStream.Close
tStream.Type = 1
tStream.Mode = 3
tStream.Open
oUpFileStream.Position = iInfoEnd
oUpFileStream.CopyTo tStream,iFormStart-iInfoEnd-2
tStream.Position = 0
tStream.Type = 2
tStream.CharSet = "gb2312"
sFormValue = tStream.ReadText
If Form.Exists (sFormName) Then
Form (sFormName) = Form (sFormName) & ", " & sFormValue
else
form.Add sFormName,sFormValue
End If
End If
tStream.Close
iFormStart = iFormStart+iStart+2
'如果到文件尾了就退出
Loop Until (iFormStart+2) = iFormEnd
RequestBinDate = ""
Set tStream = Nothing
End Sub
End Class
'文件属性类
Class FileInfo_Class
Dim FormName,FileName,FilePath,FileSize,FileType,FileStart,FileExt
'保存文件方法
Public Function SaveToFile (Path)
On Error Resume Next
Dim oFileStream
Set oFileStream = CreateObject ("ADODB.Stream")
oFileStream.Type = 1
oFileStream.Mode = 3
oFileStream.Open
oUpFileStream.Position = FileStart
oUpFileStream.CopyTo oFileStream,FileSize
oFileStream.SaveToFile Path,2
oFileStream.Close
Set oFileStream = Nothing
End Function
'取得文件数据
Public Function FileDate
oUpFileStream.Position = FileStart
FileDate = oUpFileStream.Read (FileSize)
End Function
End Class
%>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询