0

我使用filemanager没有问题。

这意味着当我创建帖子时,例如带有照片的文章,我可以毫无问题地完成。

但是当我尝试编辑帖子时,我放置独立按钮的部分无法加载文件管理器并给出 404 错误

也许我的主要问题是我没有完全理解的路线部分

web.php 代码

Route::group(['prefix' => 'laravel-filemanager', 'middleware' => ['web', 'auth:admin']], function () {
    \UniSharp\LaravelFilemanager\Lfm::routes();
});

Route::get('/admin/category/edit/{category}', [CategoryController::class, 'edit'])
    ->name('edit.category')
    ->middleware('auth:admin');

//update
Route::put('/admin/category/edit/{category}', [CategoryController::class, 'update'])
    ->name('update.category');

这是 create_category.blade.php

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">

    <link rel="stylesheet" href="{{asset('css/app.css')}}">

    <!--=== Tiny MCE SCRIPT === -->
    <script src="{{ asset('js/tinymce.min.js') }}"></script>
    <script>
        var editor_config = {
            path_absolute: "/",
            selector: 'textarea#editor',
            relative_urls: false,
            directionality: 'rtl',
            plugins: [
                "advlist autolink lists link image charmap print preview hr anchor pagebreak",
                "searchreplace wordcount visualblocks visualchars code fullscreen",
                "insertdatetime media nonbreaking save table directionality",
                "emoticons template paste textpattern"
            ],
            toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image media | rtl ltr",
            file_picker_callback: function (callback, value, meta) {
                var x = window.innerWidth || document.documentElement.clientWidth || document.getElementsByTagName('body')[0].clientWidth;
                var y = window.innerHeight || document.documentElement.clientHeight || document.getElementsByTagName('body')[0].clientHeight;

                var cmsURL = editor_config.path_absolute + 'laravel-filemanager?editor=' + meta.fieldname;
                if (meta.filetype == 'image') {
                    cmsURL = cmsURL + "&type=Images";
                } else {
                    cmsURL = cmsURL + "&type=Files";
                }

                tinyMCE.activeEditor.windowManager.openUrl({
                    url: cmsURL,
                    title: 'Filemanager',
                    width: x * 0.8,
                    height: y * 0.8,
                    resizable: "yes",
                    close_previous: "no",
                    onMessage: (api, message) => {
                        callback(message.content);
                    }
                });
            }
        };

        tinymce.init(editor_config);
    </script>
    <script src="https://code.jquery.com/jquery-3.6.0.js"
            integrity="sha256-H+K7U5CnXl1h5ywQfKtSj8PCmoN9aaq30gDh27Xc0jk=" crossorigin="anonymous"></script>


    <script src="/vendor/laravel-filemanager/js/stand-alone-button.js"></script>

    <title>test tiny mce editor with image and file upload</title>
</head>
<body>

<textarea id="editor"></textarea>

<hr>

<div class="input-group">
   <span class="input-group-btn">
     <a id="lfm" data-input="thumbnail" data-preview="holder" class="btn btn-primary">
       <i class="fa fa-picture-o"></i> Choose
     </a>
   </span>
    <input id="thumbnail" class="form-control" type="text" name="filepath">
</div>
<img id="holder" style="margin-top:15px;max-height:100px;">


<script>
    var route_prefix = "laravel-filemanager";
    $('#lfm').filemanager('image', {prefix: route_prefix});
</script>


</body>
</html>

到目前为止,一切正常,但是在 edit_category.blade.php 中,当我单击编辑页面上的按钮时,我看到 404 错误我知道我的问题与路线有关,但我不知道如何解决它

edit_cateogry.blade.php 独立按钮

{{--========== file manager--}}
                <div class="input-group">
               <span class="input-group-btn">
                 <a id="lfm" data-input="thumbnail" data-preview="holder" class="btn btn-primary">
                   <i class="fa fa-picture-o"></i> Choose
                 </a>
               </span>
                    <input id="thumbnail" contenteditable="false" class="form-control" type="text" name="filepath">
                    <br>
                </div>
                @error('filepath')
                <label class="aslert alert-danger badge-pill">{{$message}}</label>
                @enderror

                <img id="holder" style="margin-top:15px;max-height:100px;">
                <script>
                    var route_prefix = "laravel-filemanager";
                    $('#lfm').filemanager('image', {prefix: route_prefix});
                </script>
4

2 回答 2

0

你使用什么版本的 Laravel 和包?

如果您使用的是 laravel 8 版本,请安装此版本的软件包:

“unisharp/laravel-filemanager”:“v2.2.0”

于 2021-09-13T17:42:32.993 回答
0

我用这个解决它

var route_prefix = "{{route('unisharp.lfm.show')}}";
于 2021-09-13T19:10:56.913 回答