CKEditor上传图像不起作用当我上传图像时,我看到此错误。
文件上传期间发生HTTP错误(404:找不到文件)。
我在控制台中看到此错误
web.php
Route::post('/images', 'DashboardController@uploadImageSubject');
DashboardController.php
public function uploadImageSubject()
{
$this->validate(request() , [
'upload' => 'required|mimes:jpeg,png,bmp',
]);
$year = Carbon::now()->year;
$imagePath = "/upload/images/{$year}/";
$file = request()->file('upload');
$filename = $file->getClientOriginalName();
if(file_exists(public_path($imagePath) . $filename)) {
$filename = Carbon::now()->timestamp . $filename;
}
$file->move(public_path($imagePath) , $filename);
$url = $imagePath . $filename;
return "<script>window.parent.CKEDITOR.tools.callFunction(1 , '{$url}' , '')</script>";
}