In this example, we are going to show you how to How to import excel and CSV file in CodeIgniter framework MySQL PHP.
There are 3 steps in which this can be done
First, you have to download this library and past it into the “third_party” folder inside the “application” folder
Step 1:
First create a form that will take a excel file from user and send it to our server.
The code is as follows
This page will be your home page
<form action=”action.php” method=”post” enctype=”multipart/form-data”>
<div class=”form-group”>
<label for=”title”>select_file</label>
<input class=”form-control” type=”file” id=”file” name=”file” required>
<small class=”text-muted”>select_xlsx_file_format</small>
</div>
<div class=”text-right”>
<input type=”submit” name=”preview” value=”upload” class=”btn btn-success”>
</div>
</form>
Step 2:
Now in model make 2 functions one to upload the excel file and another is to save the data.