HTTP error occurred during file upload (404: File not found).

Posted 1 month ago by irankhosravi

CKEditor upload image not working When I upload a image I see this error.

HTTP error occurred during file upload (404: File not found).

web.php

Route::post('/images', '[email protected]');

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>";
}

Please sign in or create an account to participate in this conversation.