[ Mini Kiebo ]
Server: Windows NT AKFAR_SERVER 10.0 build 26200 (Windows 10) AMD64
Path:
D:
/
xampp
/
htdocs
/
peminjaman_barang
/
[
Home
]
File: import_barang.php
<?php include 'koneksi.php'; require 'vendor/autoload.php'; use PhpOffice\PhpSpreadsheet\IOFactory; if (isset($_POST['import'])) { $file = $_FILES['file']['tmp_name']; $spreadsheet = IOFactory::load($file); $sheetData = $spreadsheet->getActiveSheet()->toArray(); foreach ($sheetData as $index => $row) { if ($index == 0) continue; // skip header $nama = $row[0]; $jumlah = $row[1]; $lokasi = $row[2]; mysqli_query($conn, "INSERT INTO barang(nama_barang,jumlah,lokasi) VALUES('$nama','$jumlah','$lokasi')"); } echo "Data barang berhasil diimport!"; } ?> <form method="post" enctype="multipart/form-data"> <input type="file" name="file" accept=".xlsx,.xls"> <button type="submit" name="import">Import</button> </form>