I
I
Igor M2018-03-22 15:49:24
Yii
Igor M, 2018-03-22 15:49:24

FroalaEditor insert image into text?

Problem essence:
There is a certain textarea from FroalaEditor. I need to insert an image into the text, but when uploading, I get the message "Something went wrong. Please try again."
Here is an example code from the controller:

public function actionUploadImage()
    {
        try {
            $path = Yii::getAlias('@webroot/uploads/articles/') . Yii::$app->user->id . '/';

            if (!file_exists($path)) {
                mkdir($path, 0755);
                chmod($path, 0755);
            }

            $path = '/uploads/articles/' . Yii::$app->user->id . '/';

            $response = froala\FroalaEditor\Image::upload($path);
            echo stripslashes(json_encode($response));
        } catch (\Exception $e) {
            http_response_code(404);
        }
    }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question