Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Summernote Image Upload #125

Open
Dejmienwp opened this issue Jan 24, 2022 · 0 comments
Open

Summernote Image Upload #125

Dejmienwp opened this issue Jan 24, 2022 · 0 comments

Comments

@Dejmienwp
Copy link

Why this is not working ?
I wanna upload img summernote on folder where is ID - POST ...

I will try $id, $rows['id'] - always i have code " /169160a0-693f-489c-b5cb-0b979cb4aa68"

    /**
    * image upload from WYSIWYG
    */
    public function postEditorUpload($id = null)
    {
        header('Content-type: application/json');
        $rows = $this->db('blog')->where('id', $id)->oneArray();
        $dir    = $this->_uploads.'/'.$rows['id'];
        $error    = null;

        if (!file_exists($dir)) {
            mkdir($dir, 0777, true);
        }

        if (isset($_FILES['file']['tmp_name'])) {
            $img = new \Inc\Core\Lib\Image;

            if ($img->load($_FILES['file']['tmp_name'])) {
                $imgPath = $dir."/".time().'.'.$img->getInfos('type');
                $img->save($imgPath);
                echo json_encode(['status' => 'success', 'result' => url($imgPath)]);
            } else {
                $error = $this->lang('editor_upload_fail');
            }

            if ($error) {
                echo json_encode(['status' => 'failure', 'result' => $error]);
            }
        }
        exit();
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant