wilz's avatar
Level 1

Cannot read properties of undefined (reading 'then')

this is my js code to upload image

Route::post('upload-image', [PageController::class, 'upload'])->name('ckeditor.upload');

this is my route

public function upload(Request $request) { if ($request->hasFile('file')) { $file = $request->file('file'); $filename = time() . '_' . $file->getClientOriginalName(); $path = public_path('data');

            // Ensure the directory exists
            if (!File::exists($path)) {
                File::makeDirectory($path, 0755, true);
            }

            // Move the file to the specified directory
            $file->move($path, $filename);

            $url = url('public/data/' . $filename);

            return response()->json(['location' => $url]);
        }
        return response()->json(['error' => 'No file uploaded'], 400);
    }

this is my controller logic

but when i am trying to upload the image from the text editor tiny mce i am getting the popup message

Cannot read properties of undefined (reading 'then')

how can i solve this

0 likes
2 replies
wilz's avatar
Level 1

this is my js code please help

Snapey's avatar

format your question

put three backticks ``` on their own line before and after code blocks

Please or to participate in this conversation.