public function tinymceUploadAction(Request $request)
    {
        // TODO check admin ?

        if (!$request->isXmlHttpRequest()) {
            throw new NotFoundHttpException();
        }

        $name = $request->request->get('name');
        $base64 = $request->request->get('data');

        $filename = md5(time().uniqid()).".jpg";
        $data = explode(',', $base64);
        if (2 != count($data)) {
            throw new \InvalidArgumentException('Invalid image data.');
        }

        $fs = $this->get('local_tinymce_filesystem');
        if (!$fs->put($filename, base64_decode($data[1]))) {
            throw new \Exception('Failed to create image.');
        }

        return new JsonResponse([
            'location' => '/tinymce/' . $filename,
        ]);
    }
public function tinymceUploadAction(Request $request)
    {
        // TODO check admin ?

        if (!$request->isXmlHttpRequest()) {
            throw new NotFoundHttpException();
        }

        $name = $request->request->get('name');
        $base64 = $request->request->get('data');

        $filename = md5(time().uniqid()).".jpg";
        $data = explode(',', $base64);
        if (2 != count($data)) {
            throw new \InvalidArgumentException('Invalid image data.');
        }

        $fs = $this->get('local_tinymce_filesystem');
        if (!$fs->put($filename, base64_decode($data[1]))) {
            throw new \Exception('Failed to create image.');
        }

        return new JsonResponse([
            'location' => '/tinymce/' . $filename,
        ]);
    }
public function tinymceUploadAction ( Request $ request ) { // TODO check admin ? if ( ! $ request -> isXmlHttpRequest ( ) ) { throw new NotFoundHttpException ( ) ; } $ name = $ request -> request -> get ( 'name' ) ; $ base64 = $ request -> request -> get ( 'data' ) ; $ filename = md5 ( time ( ) . uniqid ( ) ) . ".jpg" ; $ data = explode ( ',' , $ base64 ) ; if ( 2 != count ( $ data ) ) { throw new \ InvalidArgumentException ( 'Invalid image data.' ) ; } $ fs = $ this -> get ( 'local_tinymce_filesystem' ) ; if ( ! $ fs -> put ( $ filename , base64_decode ( $ data [ 1 ] ) ) ) { throw new \ Exception ( 'Failed to create image.' ) ; } return new JsonResponse ( [ 'location' => '/tinymce/' . $ filename , ] ) ; }
Handle tinymce upload.

@param Request $request
@return JsonResponse
@throws \Exception
Handle tinymce upload .