Did you see an error in your dev tools? Did you link your storage via php artisan storage:link?
HTTP error occurred during file upload (404: File not found).
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', '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>";
}
@EJDELMONICO - I see this error in console. And when I php artisan storage:link
I get this message The [public/storage] directory has been linked.
Cannot see "HTTP error occurred during file upload (404: File not found)" there
The only warning is that you don't have a css source map
@SNAPEY - I copied bootstrap.min.css.map file in my project. But I see this error in console.
Have you add in your form enctype="multipart/form-data" ?
Error code: cloudservices-no-toke-url
i think you may need the ckeditor cloud service token?
perhaps try to upload without the ckeditor first to confirm the error not related to ckeditor.
@MUNAZZIL - YES
@SIANGBOON - How to fix the problem?
Can you check with below command in your CMD and post here?,
php artisan route:list
I see this message.
POST | admin/images | | App\Http\Controllers\Admin\DashboardController@uploadImageSubject | web,auth:web,checkAdmin |
Have you using any middleware ? then you have to change the Route as like below and use the name for form then it is easy for your action,
action="{{route('images')}}"
Route::post('images', 'Admin/DashboardController@uploadImageSubject')->name('images');
@MUNAZZIL - My form is here: I need Route::resource('blog', 'BlogController');
<form class="form-horizontal" action="{{ route('blog.store') }}" method="post" enctype="multipart/form-data">
{{ csrf_field() }}
@include('Admin.layouts.errors')
<div class="form-group">
<label for="title">title</label>
<input type="text" class="form-control" id="title" name="title" placeholder="title" value="{{ old('title') }}">
</div>
<div class="form-group">
<label for="body">body</label>
<textarea class="form-control" rows="10" id="body" name="body" placeholder="body">{{ old('body') }}</textarea>
</div>
Do you mean ? action="{{ route('blog.store' , 'images') }}"
web.php
Route::resource('blog', 'BlogController');
@munazzil and @irankhosravi - a perfect match. You guys can keep yourselves busy for days and not bother the rest of us.
@SNAPEY - I made you upset. I have a thousand discomfort. I do everything and see the error. I have no one to help me.
You are Master. Help me
@irankhosravi The error is pretty clear right. You're missing the cloud service token.
Documentation: https://ckeditor.com/docs/ckeditor4/latest/guide/dev_errors.html#cloudservices-no-token-url
First you need to ask yourself if you really need this plugin at all. If you want to store the images yourself you don't need this plugin at all.
If you do want this plugin you can find more about how to set this up here: https://ckeditor.com/docs/cs/latest/guides/token-endpoints/tokenendpoint.html
by the way, I do not see your input file in the html code.
It should be like this:
<input type="file" name="upload">
@TANGENTE - This is my HTML..
@extends('Admin.master')
@section('style')
<link rel="stylesheet" href="{{ asset('themes/css/bootstrap-select.min.css') }}">
@endsection
@section('content')
<div class="col-md-9">
<h1 class="mb-5">ایجاد بلاگ</h1>
<div class="container">
<form class="form-horizontal" action="{{ route('images') }}" method="post" enctype="multipart/form-data">
{{ csrf_field() }}
@include('Admin.layouts.errors')
<div class="form-group">
<label for="title">title</label>
<input type="text" class="form-control" id="title" name="title" placeholder="title" value="{{ old('title') }}">
</div>
<div class="form-group">
<label for="body">body</label>
<textarea class="form-control" rows="10" id="body" name="body" placeholder="body">{{ old('body') }}</textarea>
</div>
<div class="form-group">
<label for="image">image</label>
<div class="custom-file">
<input type="file" class="custom-file-input" id="image" name="image">
<label class="custom-file-label" for="image">image</label>
</div>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary">save</button>
</div>
</form>
</div>
</div>
@endsection
@section('script')
<script src="{{ asset('themes/ckeditor/ckeditor.js') }}"></script>
<script>
CKEDITOR.replace('body', {
filebrowserUploadUrl : '/admin/panel/upload-image',
filebrowserImageUploadUrl : '/admin/panel/upload-image'
});
</script>
@endsection
Try changing your public paths to storage_path()
$imagePath = "/upload/images/{$year}/";
...
if(file_exists(public_path($imagePath) . $filename)) {
$filename = Carbon::now()->timestamp . $filename;
}
$file->move(public_path($imagePath) , $filename);
To:
$imagePath = storage_path("/upload/images/".{$year});
...
if(file_exists(storage_path($imagePath) . $filename)) {
$filename = Carbon::now()->timestamp . $filename;
}
$file->move(storage_path($imagePath) , $filename);
Are these valid routes in your application?
filebrowserUploadUrl : '/admin/panel/upload-image',
filebrowserImageUploadUrl : '/admin/panel/upload-image'
ok
@SNAPEY - NO
Can you show your web.php ?
because your using DashboardController but in your form having BlogController,
According to php artisan route:list you have to use below route in your web.php your missing Admin in your route check with below one,
Route::post('images', 'Admin\DashboardController@uploadImageSubject')->name('images');
and your form look like below,
<form class="form-horizontal" action="{{ route('images') }}" method="post" enctype="multipart/form-data">
@MUNAZZIL - web.php
<?php
Route::get('/', 'HomeController@index')->name('homepage');
Route::get('/home', 'HomeController@index')->name('home');
Route::get('/findIDProvince', 'Auth\RegisterController@findIDProvince');
Route::get('/service/{serviceSlug}', 'ServiceController@single');
Route::get('/blog/{blogSlug}', 'BlogController@single');
Route::get('/machines', 'MachineController@index')->name('machines');
Route::get('/networks', 'NetworkController@index')->name('networks');
Route::get('/computers', 'ComputerController@index')->name('computers');
Route::get('/internets', 'InternetController@index')->name('internets');
Route::post('/machines/store', 'MachineController@store')->name('machines.store');
Route::post('/networks/store', 'NetworkController@store')->name('networks.store');
Route::post('/computers/store', 'ComputerController@store')->name('computers.store');
Route::post('/internets/store', 'InternetController@store')->name('internets.store');
Route::get('/code', 'HomeController@code')->name('code');
Route::post('/send', 'HomeController@send')->name('send');
Route::namespace('Admin')->middleware(['auth:web', 'checkAdmin'])->prefix('admin')->group(function (){
Route::get('dashboard', 'DashboardController@index')->name('dashboard.index');
Route::post('/images', 'DashboardController@uploadImageSubject')->name('images');
Route::resource('categories', 'CategoryController');
Route::resource('menus', 'MenuController');
Route::resource('orders', 'OrderController');
Route::put('orders/{order}/un_status', 'OrderController@un_status')->name('orders.un_status');
Route::resource('products', 'ProductController');
Route::resource('faq', 'FaqController');
Route::resource('blogs', 'BlogController');
Route::resource('slideshows', 'SlideshowController');
Route::resource('services', 'ServiceController');
Route::resource('roles', 'RoleController');
Route::resource('permissions', 'PermissionController');
Route::group(['prefix' => 'users'], function (){
Route::get('/', 'UserController@index')->name('users.index');
Route::resource('level', 'LevelManageController', ['parameters' => ['level' => 'user']]);
Route::delete('/{user}/destroy', 'UserController@destory')->name('users.destroy');
});
});
Route::group(['middleware' => 'auth', 'prefix' => 'user/panel'], function () {
Route::get('/', 'UserController@index')->name('user.panel');
Route::get('{user}/edit', 'UserController@edit')->name('user.panel.edit');
Route::get('/update', 'UserController@update')->name('user.panel.update');
});
Route::group([], function() {
Route::get('login', 'Auth\LoginController@showLoginForm')->name('login');
Route::post('login', 'Auth\LoginController@login');
Route::post('logout', 'Auth\LoginController@logout')->name('logout');
// Registration Routes...
if ($options['register'] ?? true) {
Route::get('register', 'Auth\RegisterController@showRegistrationForm')->name('register');
Route::post('register', 'Auth\RegisterController@register');
}
// Password Reset Routes...
if ($options['reset'] ?? true) {
Route::resetPassword();
}
// Email Verification Routes...
if ($options['verify'] ?? false) {
Route::emailVerification();
}
});
@IRANKHOSRAVI - You keep your route as usual and just add admin in your form as like below action="{{ route('admin.blog.store') }}",
form class="form-horizontal" action="{{ route('admin.blog.store') }}" method="post" enctype="multipart/form-data">
{{ csrf_field() }}
@include('Admin.layouts.errors')
<div class="form-group">
<label for="title">title</label>
<input type="text" class="form-control" id="title" name="title" placeholder="title" value="{{ old('title') }}">
</div>
<div class="form-group">
<label for="body">body</label>
<textarea class="form-control" rows="10" id="body" name="body" placeholder="body">{{ old('body') }}</textarea>
</div>
@MUNAZZIL - When I type in cmdphp artisan route:list I see this message blog.store
When I asked if these were in your routes
filebrowserUploadUrl : '/admin/panel/upload-image',
filebrowserImageUploadUrl : '/admin/panel/upload-image'
and you said YES what were you referring to?
Oh, I see you have deleted that reply now.
For more information about this error go to ...
Where in your screenshot does it say
HTTP error occurred during file upload (404: File not found).
What problem are we trying to solve here?
@SNAPEY - better save your time to save others, let munazzil dealing it...
Please or to participate in this conversation.

