Monday, April 10, 2017

How to redirect new page with a session message on successful laravel dropzone file upload?

I use laravel & DropZone to upload file. I want to redirect with a Session message after successful file upload. my js code is here:

 var baseUrl = "";

            Dropzone.autoDiscover = false;
             var myDropzone = new Dropzone("form#dropzoneFileUpload", { 
                 url: baseUrl+"/dropzone/uploadFiles",
             });
             Dropzone.options.myAwesomeDropzone = {
                paramName: "file", 
                maxFilesize: 2, // MB
                addRemoveLinks: true,
                accept: function(file, done) {

                },
              };

here is my controller code:

$upload_success = Input::file('file')->move($destinationPath, $fileName); 
        if ($upload_success) {
             \Session::put('success','Uploded successfully.');
            return redirect()->intend('/media');
            //return Response::json('success', 200);
        } else {
            return Response::json('error', 400);
        }

how can i use this session message & redirect to another page? This code is not working :

 \Session::put('success','Uploded successfully.');
                return redirect()->intend('/media');



via fsuuaas

Advertisement