无法使用 PHP 使用 Froala Editor 上传图片 URL

Can't Upload Image URL with Froala Editor using PHP

我在使用 php 上传图片时设置 froala 编辑器时遇到问题。

我已阅读 Froala 编辑器的文档

这是我的 js 函数:

$(function() {
    $('#edit-ru').editable({
        inlineMode: false,
        imageUploadURL: 'upload_image.php'
    }).on('editable.imageError', function (e, editor, error) {
            // Custom error message returned from the server.
            if (error.code == 0) { alert("error"); }

            // Bad link.
            else if (error.code == 1) { alert("bad link"); }

            // No link in upload response.
            else if (error.code == 2) { alert("no link"); }

            // Error during image upload.
            else if (error.code == 3) { alert("during image"); }

            // Parsing response failed.
            else if (error.code == 4) { alert("parsing error"); }

            // Image too large.
            else if (error.code == 5) { alert("large image"); }

            // Invalid image type.
            else if (error.code == 6) { alert("invalid image"); }

            // Image can be uploaded only to same domain in IE 8 and IE 9.
            else if (error.code == 7) { alert("ie8 error"); }
        }).imageInserted (e, editor, img, response)
});

和我的 upload_image.php 文件

$allowedExts = array("gif", "jpeg", "jpg", "png");

$temp = explode(".", $_FILES["file"]["name"]);

$extension = end($temp);

$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mime = finfo_file($finfo, $_FILES["file"]["tmp_name"]);

if ((($mime == "image/gif")
|| ($mime == "image/jpeg")
|| ($mime == "image/pjpeg")
|| ($mime == "image/x-png")
|| ($mime == "image/png"))
&& in_array($extension, $allowedExts)) {

$name = sha1(microtime()) . "." . $extension;

move_uploaded_file($_FILES["file"]["tmp_name"], getcwd() . "uploads/" . $name);

$response = new StdClass;
$response->link = "uploads/" . $name;
echo stripslashes(json_encode($response));}

请帮我设置一下!我什么都试过了,但 id 不能正常工作! 可能是什么原因?

提前致谢!

uploads/替换为/uploads/