【发布时间】:2015-02-23 11:04:56
【问题描述】:
我正在使用 blueimp 在 cakephp 2.x 中上传图片。图片已上传,但上传图片后出现问题。我收到错误“SyntaxError: Unexpected token SO 上找到解决方案。我试图按照解决方案中给出的答案来解决我的问题,但不能。 (抱歉英语不好) 我的控制器代码
App::import('Vendor', 'UploadHandler', array('file' => 'file.upload/UploadHandler.php'));
$this->layout = 'upload';
$options = array(
// 'upload_dir' => WWW_ROOT . DS . 'img',
'accept_file_types' => '/\.(gif|jpe?g|png)$/i',
);
$upload_handler = new UploadHandler($options);
}
我在 main.js(blueimp js 文件)中更改了 url
// Initialize the jQuery File Upload widget:
$('#fileupload').fileupload({
// Uncomment the following to send cross-domain cookies:
//xhrFields: {withCredentials: true},
url: 'index'
});
json数据显示在索引页面上。
{"files":[{"name":"1186225_383357368459160_1371777554_n.jpg","size":58938,"url":"http:\/\/localhost\/ec\/cakephp\/app\/webroot\/files\/1186225_383357368459160_1371777554_n.jpg","thumbnailUrl":"http:\/\/localhost\/ec\/cakephp\/app\/webroot\/files\/thumbnail\/1186225_383357368459160_1371777554_n.jpg","deleteUrl":"http:\/\/localhost\/ec\/cakephp\/app\/webroot\/?file=1186225_383357368459160_1371777554_n.jpg","deleteType":"DELETE"},{"name":"e0775308650b201469fc68765dc4ff7a.jpg","size":150919,"url":"http:\/\/localhost\/ec\/cakephp\/app\/webroot\/files\/e0775308650b201469fc68765dc4ff7a.jpg","thumbnailUrl":"http:\/\/localhost\/ec\/cakephp\/app\/webroot\/files\/thumbnail\/e0775308650b201469fc68765dc4ff7a.jpg","deleteUrl":"http:\/\/localhost\/ec\/cakephp\/app\/webroot\/?file=e0775308650b201469fc68765dc4ff7a.jpg","deleteType":"DELETE"}]}
【问题讨论】:
-
应该如何解决这个问题?您发布的 JSON 中甚至没有
<!
标签: cakephp blueimp image-upload