Level 1
this is my js code please help
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
Please or to participate in this conversation.