Redactor imageUpload和Laravel 4资源控制器

Redactor imageUpload和Laravel 4资源控制器,laravel,wysiwyg,image-uploading,redactor,Laravel,Wysiwyg,Image Uploading,Redactor,我见过几种使用专用路由的Redactor imageUpload解决方案,但是我选择使用资源控制器来完成所有路由 标记: <div class="row"> <div class="large-12 columns"> {{ Form::model($page, array('method' => 'put', 'route' => array('pages.update', $page->id), 'files' => t

我见过几种使用专用路由的Redactor imageUpload解决方案,但是我选择使用资源控制器来完成所有路由

标记:

<div class="row">
    <div class="large-12 columns">
        {{ Form::model($page, array('method' => 'put', 'route' => array('pages.update', $page->id), 'files' => true)) }}

        <div class="row">
            <div class="large-12 columns">
                {{ Form::label('title', 'Title') }}
                {{ Form::text('title') }}
            </div>
        </div>

        <div class="row">
            <div class="large-12 columns">
                {{ Form::label('body', 'Content') }}
                {{ Form::textarea('body') }}
            </div>
        </div>

        <div class="row">
            <div class="large-12 columns">
            {{ Form::submit('Save', array('class' => 'button')) }}
            <a href="{{ URL::route('pages.index') }}" class="btn btn-large">Cancel</a>
        </div>

    {{ Form::close() }}
    </div>
</div>

<script>
$(document).ready(function() 
{
  $(this).foundation();

  $('#body').redactor({

  iframe: true,
  css: "{{ url('sleddog-assets/stylesheets/app.css') }}",
  imageUpload: 'pages.edit'
  });

});
</script>
我的问题是:

在标记中,imageUpload的目标是哪里?编辑页面? 在控制器中,您将使Redactor的imageUpload工作所需的代码放在哪里


谢谢

要使用redactor的imageupload功能,必须为其编写自定义方法。我附上了一个例子

public function postUpload(){

    $file = Input::file('file');

    $destinationPath = 'uploads/';
    $extension = $file->getClientOriginalExtension();
    $filename  = uniqid($file->getFilename()) . '.' . $extension;
    $upload_success = Input::file('file')->move($destinationPath, $filename);

    if( $upload_success ) {
        return Response::json($data = array(
            'filelink' => Request::root() . '/' .$destinationPath . $filename
        ), 200);
    } else {
        return Response::json('error', 400);
    }
}
编校者将变成这样:

$('#redactor').redactor({
imageUpload: base + '/url/to/controller'
});
欲了解更多信息,请阅读此

您的解决方案帮了大忙。我现在唯一的问题是,我得到了一个破碎的图像结果。。。如果我右键单击,获取图像URL,它是正确的。它还可以正确地保存图像。我认为唯一导致这个问题的原因是我在我的web开发工具的源代码中得到了这个时髦的url{“filelink”:“http:\/\/localhost:8000\/public\/uploads\/phpgldSn851f8cff91ff61.jpg”}。。。知道为什么吗?谢谢如果可以的话我会投票支持你的。。。我还在想,我是否需要为上传目录声明一个路由?这就是为什么它不显示的原因吗?感谢为每个映像设置这样一个错误:GET 500(内部服务器错误)明白了。控制器不需要绝对路径!再次感谢所有的帮助!返回响应::json($data=array('filelink'=>'/uploads/'.$filename),200);在我的情况下是这样的,但是如果它对你有效的话,那就好了:)(很抱歉回复得太晚了)
$('#redactor').redactor({
imageUpload: base + '/url/to/controller'
});