-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupload.php
56 lines (43 loc) · 1.19 KB
/
upload.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
ini_set('post_max_size', '40M');
ini_set('upload_max_filesize', '40M');
if(isset($_POST['save_audio']) && $_POST['save_audio'] == "Upload Audio")
{
$dir='uploads/';
$audio_path=$dir.basename($_FILES['audioFile']['name']);
if(move_uploaded_file($_FILES['audioFile']['tmp_name'],$audio_path))
{
echo 'uploaded successfully.';
saveAudio($audio_path);
displayAudios();
}
else
saveAudio($audio_path);
}
function displayAudios(){
$conn=mysqli_connect('localhost','root','','jhoomjingle');
if(!$conn){
die('server not connected.');
}
$query="select * from jhoomjingle.audios";
$r=mysqli_query($conn, $query);
while($row = mysqli_fetch_array($r)){
echo "<br/>";
echo '<a href="play.php?name='.$row['filename'].'">'.$row['filename'].'</a>';
}
mysqli_close($conn);
}
function saveAudio($fileName){
$conn=mysqli_connect('localhost','root','','jhoomjingle');
if(!$conn){
die('server not connected.');
}
$query="insert into audios(filename)values('{$fileName}')";
mysqli_query($conn, $query);
if(mysqli_affected_rows($conn)>0)
{
echo "audio file path saved in database.";
}
mysqli_close($conn);
}
?>