With AJAX you can perform an action on the server without refreshing the whole page.
You can use it to fetch data, import file data, upload files, etc.
In this tutorial, I am using it to upload a file and display a preview if the file is an image otherwise display a link in the CodeIgniter 4 project.
I have enabled CSRF token in the CodeIgniter project.
.env
file.app/Config/Routes.php
file.UsersController.php
file in app/Controllers/
folder.Create index.php
file in app/Views/
.
Pass selected file using FormData Object to upload in AJAX request.
#ajax #codeigniter 4 #jquery #php