laravel 4 ajax image upload with redactor js, wiswig editor, CMS

In Views

<head>

<link rel="stylesheet" type="text/css" href="css/style.css" />
<script type="text/javascript" src="lib/jquery-1.9.0.min.js"></script>


<!-- Redactor is here -->
<link rel="stylesheet" href="redactor/redactor.css" />
<script src="redactor/redactor.min.js"></script>

<script type="text/javascript">
$(document).ready(
function()
{
            $('#mytext').redactor({
            imageUpload: 'redactorupload'
            });
}
);
</script>


</head>

<body>
<div>
<textarea id="mytext" cols="30" rows="30"   name="description">  </textarea>
</div>
<body>

In Controller

     Route::post('redactorupload', function()
    {
        $des=public_path();
        $file=Input::file('file');
        Input::file('file')->move($des.'\images\\',$file->getClientOriginalName());
        return Response::json(['filelink' => asset('images/'.$file->getClientOriginalName())]);
    });



In this redactorupload route will be called automatically when we browse and select the image and copy the image in public/images/ folder and that link is given to the editor using
 file move same as uploading the image in normal way but return Response::json
provide the link in the editor to show the Image on the editor




Comments

Popular posts from this blog

Bootstrap Tags Input

Laravel 5.8 Files Folders Permissions and Ownership Setup