如何在laravel 4.2中使用Dropzone

如何在laravel 4.2中使用Dropzone,laravel,laravel-4,dropzone.js,Laravel,Laravel 4,Dropzone.js,我想将“Dropzone”与Laravel4.2结合到我的网站上,我在他们的官方网站上找到了一个例子 但是,当我将其添加到表单时,表单会改变行为,并且我无法在控制器中处理图像。你能给我一个使用Laravel 4.2的dropzone的基本示例吗 <script> var myDropzone = new Dropzone("div#dropzone", { url: "{{URL:

我想将“Dropzone”与Laravel4.2结合到我的网站上,我在他们的官方网站上找到了一个例子

但是,当我将其添加到表单时,表单会改变行为,并且我无法在控制器中处理图像。你能给我一个使用Laravel 4.2的dropzone的基本示例吗

<script>
                        var myDropzone = new Dropzone("div#dropzone", {
                            url: "{{URL::route('compose-attachment')}}",
                            //clickable: "#yourSubmitButton",
                            paramName: "file",
                            addRemoveLinks: true,
                            init: function() {

                                        });
                                    });
                            }
                        });
                    </script>
控制器:

public function getPostAttachment(){


 $file = Input::file('file');
 $destinationPath =  public_path().'/uploads';
 $time = time();

 $filename = $time."-".$file->getClientOriginalName(); 
 $upload_success = Input::file('file')->move($destinationPath, $filename);
 }

这是我的视图代码:

{{ Form::open(array('files'=> true  , 'method' => 'post' ,'route' => array('article.create', Route::current()->getParameter('lang')))) }}

                  <div class="fallback" id = "dropzone" >
                    <input name="file" type="file" multiple />
                  </div>

        {{ Form::submit(Lang::get('messages.create') , array('class' => 'btn btn-default custom-submit')) }}

    {{ Form::close() }}
<script>
var myDropzone = new Dropzone("div#dropzone", {
    url: "{{URL::route('compose-attachment')}}",
    //clickable: "#yourSubmitButton",
    paramName: "file",
    addRemoveLinks: true,
    init: function() {

                });
            });
    }
});
</script>
控制器:

public function getPostAttachment(){
        $file = Input::file('file');
        return var_dump($file);
    }

我收到了此错误(路由[/compose attachment]未定义。)您的控制器是否也命名为UserController?ArticleController,但我将路由重命名为:路由::post('/compose attachment',数组('as'=>'postMsgAttachment','uses'=>'ArticleController@getPostAttachment'));您应该有两个路由:Route::post('/compose attachment',array('as'=>'postsgattachment','uses'=>'ArticleController@getPostAttachment')); 发布dropzone文件。以及渲染视图的get路径。控制器也是如此。在你的控制器中,你应该有两个函数,一个是两个渲染视图,这是你的“获取”路线,另一个是“发布”路线。我有两个路线,你能给我另外的表格代码吗(表格包含drapzone div)
Route::post('/compose-attachment', array( 'as' => 'postMsgAttachment','uses' => 'ArticleController@getPostAttachment'));
public function getPostAttachment(){
        $file = Input::file('file');
        return var_dump($file);
    }