Ckeditor 5 - 无法上传文件:logo.jpg / codeigniter 4

发布于 2025-01-09 03:00:24 字数 1456 浏览 0 评论 0原文

我正在尝试实现 ckeditor5 和 SimpleUploadAdapter。我收到错误,无法上传文件:logo.jpg

ClassicEditor
.create( document.querySelector( '#post_body' ), {
  
    simpleUpload: {
        // The URL that the images are uploaded to.
        uploadUrl: 'https://example.com/upload/posts/',

        // Enable the XMLHttpRequest.withCredentials property.
        withCredentials: true,

        // Headers sent along with the XMLHttpRequest to the upload server.
        headers: {
             
            'X-CSRF-TOKEN': +CKeditorToken_name,
            Authorization: 'Bearer ' +CKeditorToken_hash,
        }
    }
} )
.catch( error => {
        console.error( error );
} );

我对 X-CSRF-TOKENAuthorization 有点困惑要求。我正在传递 csrf_token() 的值,这是当前 CSRF 令牌的名称和 csrf_hash() 这是 CSRF 哈希的当前值。这是这里所需要的吗?

另外,对于上传网址,这是正确的;

uploadUrl: 'https://example.com/upload/posts/

或者 uploadUrl: 'https://example.com/upload/posts

在控制台中,显示以下错误:

simpleuploadadapter.js:224          POST https://example.com/upload/posts/ 404 (Not Found)

非常感谢任何指针或指导。

我对目录权限和路径进行了双重和三次检查,一切都很好。

I am trying to implement ckeditor5 and SimpleUploadAdapter. I get an error, Couldn't upload file: logo.jpg

ClassicEditor
.create( document.querySelector( '#post_body' ), {
  
    simpleUpload: {
        // The URL that the images are uploaded to.
        uploadUrl: 'https://example.com/upload/posts/',

        // Enable the XMLHttpRequest.withCredentials property.
        withCredentials: true,

        // Headers sent along with the XMLHttpRequest to the upload server.
        headers: {
             
            'X-CSRF-TOKEN': +CKeditorToken_name,
            Authorization: 'Bearer ' +CKeditorToken_hash,
        }
    }
} )
.catch( error => {
        console.error( error );
} );

I am a bit confused as to what X-CSRF-TOKEN and Authorization require. I am passing the value of csrf_token() which is the name of the current CSRF token and csrf_hash() which is the current value of the CSRF hash. Is that what is needed here?

Also, for the upload url, which is correct;

uploadUrl: 'https://example.com/upload/posts/

or
uploadUrl: 'https://example.com/upload/posts

In the console, the following error is shown:

simpleuploadadapter.js:224          POST https://example.com/upload/posts/ 404 (Not Found)

Any pointer or guidance much appreciated.

I have double and triple checked directory permissions and path and all are ok.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文