blueimp jquery上传语法错误:意外令牌< [英] blueimp jquery upload SyntaxError: Unexpected token <
问题描述
我正在使用jquery库blueimp上传. 我想将图像上传到其他目录. 我刚刚修改了/server/php/ index.php 文件(仅此文件):
I'm using the jquery library blueimp upload. I want to upload images to a different directory. I just modified the /server/php/index.php file (only this file) :
error_reporting(E_ALL | E_STRICT);
require_once('UploadHandler.php');
//$upload_handler = new UploadHandler();
define(DIR_DOWNLOAD, "/Applications/XAMPP/htdocs/villalba2");
define(HTTP_SERVER, "localhost/villalba2");
$blogId= "Mobiliario";
$upload_handler = new UploadHandler(array(
'upload_dir' => DIR_DOWNLOAD . '/uploads/' . $blogId. '/',
'upload_url' => HTTP_SERVER . '/uploads/' . $blogId. '/',
));
权限文件夹为777
图像已正确加载到我想要的目录中,但出现此错误:
The images are loaded correctly in the directory that i want, but I get this error:
Chrome-> SyntaxError:意外令牌<
Safari-> SyntaxError:JSON解析错误:无法识别的令牌'<'
Chrome ->SyntaxError: Unexpected token <
Safari ->SyntaxError: JSON Parse error: Unrecognized token '<'
/server/php/ index.php 的结果是:
The result of /server/php/index.php is:
<b>Notice</b>: Use of undefined constant DIR_DOWNLOAD - assumed 'DIR_DOWNLOAD' in <b>/Applications/XAMPP/xamppfiles/htdocs/villalba2/up/server/php/index.php</b> on line <b>16</b><br />
<br />
<b>Notice</b>: Use of undefined constant HTTP_SERVER - assumed 'HTTP_SERVER' in <b>/Applications/XAMPP/xamppfiles/htdocs/villalba2/up/server/php/index.php</b> on line <b>17</b><br />
{"files":[{"name":"cama (1).jpg","size":101775,"url":"localhost\/villalba2\/uploads\/Mobiliario\/cama%20%281%29.jpg","thumbnailUrl":"localhost\/villalba2\/uploads\/Mobiliario\/thumbnail\/cama%20%281%29.jpg","deleteUrl":"http:\/\/localhost\/villalba2\/up\/server\/php\/?file=cama%20%281%29.jpg","deleteType":"DELETE"},{"name":"cama (2).jpg","size":101775,"url":"localhost\/villalba2\/uploads\/Mobiliario\/cama%20%282%29.jpg","thumbnailUrl":"localhost\/villalba2\/uploads\/Mobiliario\/thumbnail\/cama%20%282%29.jpg","deleteUrl":"http:\/\/localhost\/villalba2\/up\/server\/php\/?file=cama%20%282%29.jpg","deleteType":"DELETE"},{"name":"cama (3).jpg","size":101775,"url":"localhost\/villalba2\/uploads\/Mobiliario\/cama%20%283%29.jpg","thumbnailUrl":"localhost\/villalba2\/uploads\/Mobiliario\/thumbnail\/cama%20%283%29.jpg","deleteUrl":"http:\/\/localhost\/villalba2\/up\/server\/php\/?file=cama%20%283%29.jpg","deleteType":"DELETE"},{"name":"cama.jpg","size":101775,"url":"localhost\/villalba2\/uploads\/Mobiliario\/cama.jpg","thumbnailUrl":"localhost\/villalba2\/uploads\/Mobiliario\/thumbnail\/cama.jpg","deleteUrl":"http:\/\/localhost\/villalba2\/up\/server\/php\/?file=cama.jpg","deleteType":"DELETE"},{"name":"mantelera.jpg","size":50986,"url":"localhost\/villalba2\/uploads\/Mobiliario\/mantelera.jpg","thumbnailUrl":"localhost\/villalba2\/uploads\/Mobiliario\/thumbnail\/mantelera.jpg","deleteUrl":"http:\/\/localhost\/villalba2\/up\/server\/php\/?file=mantelera.jpg","deleteType":"DELETE"},{"name":"test (1).png","size":15,"url":"localhost\/villalba2\/uploads\/Mobiliario\/test%20%281%29.png","deleteUrl":"http:\/\/localhost\/villalba2\/up\/server\/php\/?file=test%20%281%29.png","deleteType":"DELETE"},{"name":"test (2).png","size":15,"url":"localhost\/villalba2\/uploads\/Mobiliario\/test%20%282%29.png","deleteUrl":"http:\/\/localhost\/villalba2\/up\/server\/php\/?file=test%20%282%29.png","deleteType":"DELETE"},{"name":"test.png","size":15,"url":"localhost\/villalba2\/uploads\/Mobiliario\/test.png","deleteUrl":"http:\/\/localhost\/villalba2\/up\/server\/php\/?file=test.png","deleteType":"DELETE"}]}
为什么不起作用?图像将上传到正确的文件夹中:S
Why dosen't work?? the images are upload in the correct folder :S
谢谢!
---这最后一部分已解决-----
---THIS LAST PART IS SOLVED-----
现在,拇指未显示在浏览器中.
Now the the thumbs are not displayed on the browser..
无法加载资源:服务器响应状态为404(未找到)/localhost/villalba2/up/localhost/villalba2/uploads/Mobiliario/thumbnail/mbiliario.jpg
Failed to load resource: the server responded with a status of 404 (Not Found) /localhost/villalba2/up/localhost/villalba2/uploads/Mobiliario/thumbnail/mbiliario.jpg
正确的绝对路径将是:
/localhost/villalba2/uploads/Mobiliario/thumbnail/mbiliario.jpg
/localhost/villalba2/uploads/Mobiliario/thumbnail/mbiliario.jpg
路径: /localhost/villalba2/up/是blueimp jquery上传核心在哪里
the path: /localhost/villalba2/up/ is where is the blueimp jquery upload core
推荐答案
为了定义常量,它们必须在定义中加引号-
In order to define constants they must be quoted in the definition -
define("DIR_DOWNLOAD", "/Applications/XAMPP/htdocs/villalba2");
define("HTTP_SERVER", "localhost/villalba2");
这篇关于blueimp jquery上传语法错误:意外令牌<的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!