I want to upload excel files and store that data to my db. Sometimes it contain large data because it is leave management or kpi files. I want to export my excel file and get all data along with sub tables(pivot tables) from that file. And the files are contain different data. Please give me your valuable suggestions.
You can upload Excel files just like you upload normal files in PHP. Nothing special about Excel. However, if you want to parse the data in excel, as k102 pointed out phpExcel is a nice option.
If your question was about PHP file uploads then, refer PHP Manual
First, your Excel file has to be in CSV format, otherwise it will be a lot more difficult to insert data in your database (you have to parse it with PhpExcel for example).
If your Excel file is CSV, then you have to use LOAD DATA INFILE.
You can see an example here : https://stackoverflow.com/a/10897669/1788704
And you can have a look on below code if it helps you
$row = 1;
if (($fh = fopen("excel.csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) {
$num = count($data);
$row++;
for ($c=0; $c < $num; $c++) {
//make query and insert into database
}
}
fclose($handle);
}