【问题标题】:blueimp jquery upload SyntaxError: Unexpected token <blueimp jquery 上传 SyntaxError: Unexpected token <
【发布时间】: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 中甚至没有 &lt;

标签: cakephp blueimp image-upload


【解决方案1】:

我有同样的问题。 这是验证变量

错了

public $validate;

正确

public $validate = array();

【讨论】:

    猜你喜欢
    • 2013-03-21
    • 1970-01-01
    • 1970-01-01
    • 2011-04-02
    • 1970-01-01
    • 2016-04-06
    • 2013-09-18
    • 1970-01-01
    相关资源
    最近更新 更多