无法安装tinyMCE和UniSharp / laravel-filemanager

时间:2016-10-07 14:37:04

标签: php laravel tinymce

所以我试图通过图片上传安装tinyMCE。我成功安装tinyMCE用于简单的样式,但我无法使图像上传工作。我尝试安装UniSharp / laravel-filemanager但是当我点击img图标时这就是我得到的

Sorry page not found

Console

我认为cmsURL

有问题

这是index.blade.php

@extends('templates.layout')

@section('head')
  <script src="/wysiwyg/public/js/tinymce/tinymce.min.js"></script>
  <script>
    var editor_config = {
      path_absolute : "{{ URL::to('/') }}/",
      selector : "textarea",
      plugins: [
        "advlist autolink lists link image charmap print preview hr anchor pagebreak",
        "searchreplace wordcount visualblocks visualchars code fullscreen",
        "insertdatetime media nonbreaking save table contextmenu directionality",
        "emoticons template paste textcolor colorpicker textpattern"
      ],
      toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image media",
      relative_urls: false,
      file_browser_callback : function(field_name, url, type, win) {
        var x = window.innerWidth || document.documentElement.clientWidth || document.getElementByTagName('body')[0].clientWidht;
        var y = window.innerHeight|| document.documentElement.clientHeight|| document.grtElementByTagName('body')[0].clientHeight;
        var cmsURL = editor_config.path_absolute+'laravel-filemanaget?field_name'+field_name;
        if (type = 'image') {
          cmsURL = cmsURL+'&type=Images';
        } else {
          cmsUrl = cmsURL+'&type=Files';
        }

        tinyMCE.activeEditor.windowManager.open({
          file : cmsURL,
          title : 'Filemanager',
          width : x * 0.8,
          height : y * 0.8,
          resizeble : 'yes',
          close_previous : 'no'
        });
      }
    };

    tinymce.init(editor_config);
  </script>
@stop

@section('body')
  <h1>Hello</h1>
  <form method="post" action="addpost">
    {{ csrf_field() }}
    <textarea name="body"></textarea>
    <button type="submit">Submit</button>
  </form>

@stop

这是溃败

Route::get('/', 'HomeController@index');
Route::post('/addpost', 'HomeController@addPost');
Route::get('/{post}', 'HomeController@post');

这是家庭控制器

namespace App\Http\Controllers;

use App\Post;

use Illuminate\Http\Request;

use App\Http\Requests;

class HomeController extends Controller
{
    public function index()
    {
      return view('index');
    }

    public function post(Post $post)
    {
      return view('post', compact('post'));
    }

    public function addPost(Request $request)
    {
      $post = new Post;
      $post->body = $request->body;
      $post->save();

      return back();
    }
}

我有一个模特帖子

namespace App;

use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
    protected $fillable = ['body'];
}

1 个答案:

答案 0 :(得分:1)

如果您按照建议here正确安装laravel-filemanager

然后在代码中为'/'变量赋值时,只需将editor_config.path_absolute代替cmsURL,就可以解决Laravel 5.4中的问题。

希望它有所帮助。 没有为其他版本的Laravel检查此解决方案。

此解决方案仅针对Laravel 5.4进行测试。