我在本地计算机(mac osx 默认服务器)上设置了这个多文件上传插件( https://github.com/blueimp/jQuery-File-Upload )。一切工作正常,当我上传图像时,我收到此响应
[{
"name":"subaru-wrx-poster-i3(1).jpg",
"size":142583,"type":"image\/jpeg",
"url":"http:\/\/shipwatchpointe.dev\/bundles\/jupload\/uploads\/files\/52\/subaru-wrx-poster-i3%20%281%29.jpg",
"thumbnail_url":"http:\/\/shipwatchpointe.dev\/bundles\/jupload\/uploads\/thumbnails\/52\/subaru-wrx-poster-i3%20%281%29.jpg",
"delete_url":"http:\/\/shipwatchpointe.dev\/upload\/upload\/?file=subaru-wrx-poster-i3%20%281%29.jpg&_method=DELETE",
"delete_type":"POST"
}]
但是,我刚刚推送到 EC2 实例上的暂存区域,现在我收到了此响应
//
前端出现错误,提示...
SyntaxError: Unexpected token /
我在我能想到的任何地方扔了一堆骰子,但我没有到达它们,但仍然得到相同的响应。 EC2 实例正在运行 Ubuntu 12.10,我确保在/etc/mime.types 中存在 application/json json,但由于某种原因,它看起来仍在尝试将其呈现为 html 并向我抛出该错误。我的临时服务器上可能存在什么问题,但本地服务器上不存在?我可以粘贴我的代码,但我怀疑有很多片段可能导致了该问题。
编辑 这是我本地服务器上的响应 header (工作正常)
Accept-Ranges:bytes
Connection:Keep-Alive
Content-Length:1532
Content-Type:image/png
Date:Wed, 03 Apr 2013 18:13:47 GMT
ETag:"30d598-5fc-4d978d09b8a80"
Keep-Alive:timeout=5, max=100
Last-Modified:Wed, 03 Apr 2013 18:13:46 GMT
Server:Apache/2.2.22 (Unix) DAV/2 PHP/5.3.15 with Suhosin-Patch mod_ssl/2.2.22
OpenSSL/0.9.8r
这是我的临时服务器上的响应 header (不工作)
Connection:Keep-Alive
Content-Encoding:gzip
Content-Length:23
Content-Type:text/html
Date:Wed, 03 Apr 2013 18:07:24 GMT
Keep-Alive:timeout=5, max=100
Server:Apache/2.2.22 (Ubuntu)
Vary:Accept-Encoding
X-Powered-By:PHP/5.3.10-1ubuntu3.6
最佳答案
此处读取文件可能存在问题。检查/Grep 登台服务器中是否有任何在奇怪位置(例如 PHP 文件的开头)具有双斜杠 //
的源文件。
它可能会运行到该文件中,错误地打印这些斜杠,并结束输出。
如果是这种情况,服务器很可能看不到 BlueImp 代码,因此所有这些简单明了的输出 header 与上传完全无关。
关于javascript - SyntaxError : Unexpected token/. .. Blueimp jQuery 文件上传,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15734235/