Site icon WDB24

How to Upload CSV and Save in Mysql database using PHP

php featured image

New to php and don’t know how to upload and save CSV file in mysql database? Don’t worry in this post I am going to discuss with you how to do that.

Before I jump into the code let’s see what we are going to do.

Steps: How to upload CSV and save in Mysql database using PHP

HTML Code

When we want to add file field in the form then we must add enctype=”multipart/form-data”. Enctype attribute identifies how the form data should be encoded when data is going to server and it can be used only if the form method is POST. $_GET[‘file’] will use to print success message and $errorMsg will print error message if file will not a CSV.


CSS

Mysql Table Structure

I am using some php built-in function to accomplish CSV Upload task here they are:

PHP Code

Exit mobile version