-
Notifications
You must be signed in to change notification settings - Fork 6
/
bio_add.php
34 lines (28 loc) · 996 Bytes
/
bio_add.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<form method="post" enctype="multipart/form-data">
<input type="file" name="biofile">
<input type="submit" name="submit" value="IMPORT">
</form>
<?php
include_once 'config/config.php';
if (isset($_POST['submit'])) {
// Check if a file was uploaded and there are no errors
if (isset($_FILES['biofile']) && $_FILES['biofile']['error'] === UPLOAD_ERR_OK) {
$uploadedFilePath = $_FILES['biofile']['tmp_name'];
$handle = fopen($uploadedFilePath, 'r');
if (!$handle) {
echo 'Failed to open uploaded file.';
exit;
}
// Rest of your code to process the file data
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
// Your database insertion code
}
// Close the file handle
fclose($handle);
// Redirect or show a success message
header("location:./Biosuccess.php");
} else {
echo 'Error uploading file.';
}
}
?>