-
Notifications
You must be signed in to change notification settings - Fork 0
/
uploadMusic.php
27 lines (26 loc) · 1.03 KB
/
uploadMusic.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
<?php
session_start();
$con = mysqli_connect("localhost", "root", "mundjeff", "files4u");
if (mysqli_connect_errno($con) > 0)
echo "connection error";
$output_dir = "uploads/";
if (isset($_FILES["myfile"])) {
$ret = array();
$error = $_FILES["myfile"]["error"];
if (!is_array($_FILES["myfile"]["name"])) { //single file
$fileName = $_FILES["myfile"]["name"];
move_uploaded_file($_FILES["myfile"]["tmp_name"], $output_dir . $_FILES["myfile"]["name"]);
$ret[$fileName] = $output_dir . $fileName;
} else {
$fileCount = count($_FILES["myfile"]["name"]);
for ($i = 0; $i < $fileCount; $i++) {
$fileName = $_FILES["myfile"]["name"][$i];
$ret[$fileName] = $output_dir . $fileName;
move_uploaded_file($_FILES["myfile"]["tmp_name"][$i], $output_dir . $fileName);
}
$i = mysqli_query($con, "insert into tb_collections (filename,email,type) values('$fileName','" . $_SESSION['currentUser'] . "',3)");
echo $i;
}
echo json_encode($ret);
}
?>