Laravel在CKEDITOR上传图片

问题描述 投票:0回答:1

当我使用从ckeditor上传图像和附加在发布我的上传图像功能在控制器工作正常没有任何问题,但当我想要返回上传的图像,ckeditor无法得到,例如这是我的代码:

控制器:

public function uploadImageContent()
{
    $this->validate(request(), [
        'upload' => 'mimes:jpeg,jpg,gif,png'
    ]);

    $file = request()->file('upload');
    $filename = $file->getClientOriginalName();

    $year = Carbon::now()->year;
    $imagePath = "/uploads/post_images/{$year}/";

    if (file_exists(public_path($imagePath) . $filename)) {
        $filename = Carbon::now()->timestamp . '.' . $filename;
    }

    $file->move(public_path() . $imagePath, $filename);

    $url = $imagePath . $filename;

    return "<script>window.parent.CKEDITOR.tools.callFunction(1,'{$url}','')</script>";
}

这个函数工作正常,我没有在qazxsw poi或qazxsw poi上得到任何错误

console

应该是返回路径,但不行。

视图:

network

路线:

return "<script>window.parent.CKEDITOR.tools.callFunction(1,'{$url}','')</script>";

ContentsController:

<script>
    $(function () {
        CKEDITOR.replace('description', {
            height: '200px',
            extraPlugins: 'forms',
            filebrowserUploadUrl:'/dashboard/administrator/attachImage',
            filebrowserImageUploadUrl:'/dashboard/administrator/attachImage'
        });

    });
</script>
php laravel laravel-5 ckeditor
1个回答
0
投票

使用Route::group(['namespace' => 'Dashboard', 'prefix' => 'dashboard'], function () { $this->group(['prefix' => 'administrator'], function () { ... $this->post('/attachImage', 'ContentsController@attachImage'); ... }); 而不是class ContentsController extends Controller { ... public function attachImage() { $this->uploadImageContent(request()->all()); } } 解决我的问题:

echo

我在return上有这个问题

© www.soinside.com 2019 - 2024. All rights reserved.