Blueimp / jQuery File Uploader不适用于漂亮的URL? (SyntaxError:意外的令牌......)

时间:2017-06-10 15:40:32

标签: php jquery file-upload friendly-url blueimp

RewriteRule ^edit_storage/(.*)$ ./edit_storage.php?object_key=$1

这就是我使用Blueimp的页面的漂亮网址。

如果写了这样的网址:/edit_storage/12345678 - 没有任何作用,但如果:/edit_storage?object_key=12345678 - 没关系,这里没有任何问题。

从某种意义上讲,“没有任何作用”,即Blueimp的gui已加载,但尚未上传文件。如果尝试上传某些内容,我会收到错误:SyntaxError: Unexpected token < in JSON at position 1

为什么呢?如何解决?

我的index.php

<?php
error_reporting(E_ALL | E_STRICT);
require($_SERVER['DOCUMENT_ROOT'] . "/plugin/blueimp/server/php/UploadHandler.php");
session_start();
$options = array (
                'upload_dir' => $_SERVER['DOCUMENT_ROOT'].'/load/'.$_SESSION['object_key'].'/',
                'upload_url' => '/load/'.$_SESSION['object_key'].'/',

                'image_versions' => array(
                    'thumbnail' => array(
                        'upload_dir' => $_SERVER['DOCUMENT_ROOT'].'/show/'.$_SESSION['object_key'].'/',
                        'upload_url' => '/show/'.$_SESSION['object_key'].'/',

                        'max_width' => 100,
                        'max_height' => 100
                    )
                )
            );
$upload_handler = new UploadHandler($options);
?>

的信息:

HTML:Apache-PHP-7-x64

PHP:PHP-7.1-x64

/ ps:我的页面以:

开头
<?php include($_SERVER['DOCUMENT_ROOT'] . "/engine/auto_include.php"); ?>
<?php
set_time_limit(5);

include($_SERVER['DOCUMENT_ROOT'] . "/engine/get_functions.php");

$thisObjectID = $_GET['object_key'];
$object_key = $_GET['object_key'];
$original_id = $_GET['original_id'];
...

对于会遇到同样问题的人!

修复很简单,但不是很明显。

// Initialize the jQuery File Upload widget:
$('#uploadTable').fileupload({
    // Uncomment the following to send cross-domain cookies:
    //xhrFields: {withCredentials: true},
    //url: 'server/php/',
    url: '/plugin/blueimp/server/php/', //Need to add "/" or "../" in start of string. Facepalm. Who is thought to do it work like that?
    ...
});

0 个答案:

没有答案