-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvoiceupload.php
More file actions
32 lines (26 loc) · 1.13 KB
/
voiceupload.php
File metadata and controls
32 lines (26 loc) · 1.13 KB
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
<?php
// Handle feature image upload
$banner_img = $_FILES['customFile1'];
$banner_imgName = generateUniqueFilename($banner_img['name']);
$banner_imgDestination = '../images/' . $banner_imgName;
move_uploaded_file($banner_img['tmp_name'], $banner_imgDestination);
$audio_file = $_FILES['customFile2'];
$audio_fileName = generateUniqueFilename($audio_file['name']);
$audio_fileDestination = '../images/audio/' . $audio_fileName;
move_uploaded_file($audio_file['tmp_name'], $audio_fileDestination);
$title = $_POST['title'];
$categories = $_POST['categories'];
$user = $_POST['user'];
// Save filenames to the database
$pdo = new PDO('mysql:host=localhost;dbname=capstone', 'root', '');
$stmt = $pdo->prepare('INSERT INTO button
(label, voice_audio, categ, icon, history, historyremove, status, user)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)');
$stmt->execute([$title, $audio_fileName, $categories, $banner_imgName, 1, 1, 1, $user]);
// Function to generate a unique filename
function generateUniqueFilename($filename)
{
$extension = pathinfo($filename, PATHINFO_EXTENSION);
return uniqid() . '.' . $extension;
}
?>