求大神指点上传图片错误

窗外的天空 2014-04-04 09:40:04
Microsoft VBScript 编译器错误 '800a0400'

缺少语句

\web\ZhiEditor\upload_json.asp, line 2



--------------------------------------------------------------------------------
Host by NetBox Version 2.8 Build 4128



web\ZhiEditor\upload_json.asp如下
<%@ CODEPAGE=65001 %>
<% Option Explicit %>
<% Response.CodePage=65001 %>
<% Response.Charset="UTF-8" %>
<!--#include file="UpLoad_Class.asp"-->
<!--#include file="JSON_2.0.4.asp"-->
<%
Dim aspUrl, savePath, saveUrl, maxSize, fileName, fileExt, newFileName, filePath, fileUrl, dirName
Dim extStr, imageExtStr, flashExtStr, mediaExtStr, fileExtStr
Dim upload, file, fso, ranNum, hash, ymd, mm, dd, result

aspUrl = Request.ServerVariables("SCRIPT_NAME")
aspUrl = left(aspUrl, InStrRev(aspUrl, "/"))

'文件保存目录路径
savePath = "../upload/"
'文件保存目录URL
saveUrl = aspUrl & "../upload/"
'定义允许上传的文件扩展名
imageExtStr = "gif|jpg|jpeg|png|bmp"
flashExtStr = "swf|flv"
mediaExtStr = "swf|flv|mp3|wav|wma|wmv|mid|avi|mpg|asf|rm|rmvb"
fileExtStr = "doc|docx|xls|xlsx|ppt|htm|html|txt|zip|rar|gz|bz2"
'最大文件大小
maxSize = 5 * 1024 * 1024 '5M

Set fso = Server.CreateObject("Scripting.FileSystemObject")
If Not fso.FolderExists(Server.mappath(savePath)) Then
showError("上传目录不存在。")
End If

dirName = Request.QueryString("dir")
If isEmpty(dirName) Then
dirName = "image"
End If
If instr(lcase("image,flash,media,file"), dirName) < 1 Then
showError("目录名不正确。")
End If

Select Case dirName
Case "flash" extStr = flashExtStr
Case "media" extStr = mediaExtStr
Case "file" extStr = fileExtStr
Case Else extStr = imageExtStr
End Select

set upload = new AnUpLoad
upload.Exe = extStr
upload.MaxSize = maxSize
upload.GetData()
if upload.ErrorID>0 then
showError(upload.Description)
end if

'创建文件夹
savePath = savePath & dirName & "/"
saveUrl = saveUrl & dirName & "/"
If Not fso.FolderExists(Server.mappath(savePath)) Then
fso.CreateFolder(Server.mappath(savePath))
End If
mm = month(now)
If mm < 10 Then
mm = "0" & mm
End If
dd = day(now)
If dd < 10 Then
dd = "0" & dd
End If
ymd = year(now) & mm & dd
savePath = savePath & ymd & "/"
saveUrl = saveUrl & ymd & "/"
If Not fso.FolderExists(Server.mappath(savePath)) Then
fso.CreateFolder(Server.mappath(savePath))
End If

set file = upload.files("imgFile")
if file is nothing then
showError("请选择文件。")
end if

set result = file.saveToFile(savePath, 0, true)
if result.error then
showError(file.Exception)
end if

filePath = Server.mappath(savePath & file.filename)
fileUrl = saveUrl & file.filename

Set upload = nothing
Set file = nothing

If Not fso.FileExists(filePath) Then
showError("上传文件失败。")
End If

Response.AddHeader "Content-Type", "text/html; charset=UTF-8"
Set hash = jsObject()
hash("error") = 0
hash("url") = fileUrl
hash.Flush
Response.End

Function showError(message)
Response.AddHeader "Content-Type", "text/html; charset=UTF-8"
Dim hash
Set hash = jsObject()
hash("error") = 1
hash("message") = message
hash.Flush
Response.End
End Function
%>
...全文
585 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
_白衣_ 2014-04-05
  • 打赏
  • 举报
回复
报错在 304 行 不见得就是真在304行的,有时候 如果前面缺少一个 什么,它只是到 304 才执行不下去而以。 而且这种错误你这些代码应该没有问题,但是还有一种非常少见的可能,就是字符的编码不对。也会出这个错误。比如引号用了非英文的,或者文件上写的是utf-8 但你实际输入的字符却是gb2312的
Go 旅城通票 2014-04-04
  • 打赏
  • 举报
回复
304行也没有错啊。。
窗外的天空 2014-04-04
  • 打赏
  • 举报
回复
引用 2 楼 showbo 的回复:
你这个文件没有错,要错也会是第二行。。
这个不是我写的东西,老板让我修改下的我对。ASP不会的呀 贼郁闷了
窗外的天空 2014-04-04
  • 打赏
  • 举报
回复
引用 2 楼 showbo 的回复:
你这个文件没有错,要错也会是第二行。。
我把第二行改了下成这样 '<%@ CODEPAGE=65001 %> <%@ LANGUAGE = VBScript.Encode CodePage = 936%> <% 'Option Explicit %> <% Response.CodePage=65001 %> <% Response.Charset="gb2312" %> <!--#include file="UpLoad_Class.asp"--> <!--#include file="JSON_2.0.4.asp"--> <% 之后错误也变了成 Microsoft VBScript 编译器错误 '800a0409' 未结束的字符串常量 \web\ZhiEditor\UpLoad_Class.asp, line 304 UpLoad_Class.asp代码 Private Function GetErr(ByVal Num) Select Case Num Case 0 GetErr = "数据处理完毕!" Case 1 GetErr = "上传数据超过" & GetSize(vMaxSize) & "限制!可设置MaxSize属性来改变限制!" Case 2 GetErr = "未设置上传表单enctype属性为multipart/form-data或者未设置method属性为Post,上传无效!" Case 3 GetErr = "含有非法扩展名(" & vErrExe & ")文件!只能上传扩展名为" & Replace(vExe, "|", ",") & "的文件"-----《低304行》 Case 4 GetErr = "对不起,程序不允许使用相同name属性的文件域!" Case 5 GetErr = "单个文件大小超出" & GetSize(vSingleSize) & "的上传限制!" End Select End Function
Go 旅城通票 2014-04-04
  • 打赏
  • 举报
回复
你这个文件没有错,要错也会是第二行。。
窗外的天空 2014-04-04
  • 打赏
  • 举报
回复
在线等,求大神解答,

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧