I'm coding the editor in the Laravel
framework and implementing the Jodit
library.
I want to add an upload for the editor. The problem is that the upload does not work for the editor. My codes are as follows.
my route
Route::prefix('')->namespace('Web')->name('')->group(function() {
Route::post('/upload', 'UploadController@index' )->name('index');
});
my UploadController.php
class UploadController extends Controller
{
public function index(Request $request)
{
$file = $request->file('file');
$file->move( storage_path('uploads') , imagetrim($file->getClientOriginalName()) );
}
}
my blade:
<textarea name="content" class="editor"></textarea>
my js:
var editor = new Jodit('.editor', {
textIcons: false,
iframe: false,
iframeStyle: '*,.jodit_wysiwyg {color:red;}',
height: 800 ,
defaultMode: Jodit.MODE_WYSIWYG,
observer: {
timeout: 100
},
commandToHotkeys: {
'openreplacedialog': 'ctrl+p'
},
uploader: {
url: '/upload'
},
});
});
Error Console:
1. Uncaught (in promise) TypeError: resp is undefined.
2. Post : http://127.0.0.1:8000/upload :> Status: 500 Internal Server Error
But I am not getting a good result, I can't upload, and the photo is not uploaded to the folder storage/uploads
. It says that resp
is not defined and you need to add it. What code should I enter for it (resp
) to be uploaded?
Please help.
If you want to use file manager or other features, you have to buy it. Because it is a paid program.