I have a small code to upload audio, however it is displaying an error of Undefined index in two lines referring to "audioFile".
Notice: Undefined index: audioFile in C: \ xampp \ apps \ wordpress \ htdocs \ upload.php on line 5
Notice: Undefined index: audioFile in C: \ xampp \ apps \ wordpress \ htdocs \ upload.php on line 6
I found several similar questions but could not solve the problem. In these queries queried, most of the time the problem was in the "enctype" statement, which I believe is not my case.
Follow the code:
form.php
<html>
<head>
<meta charset="utf-8">
<title>Upload de audio</title>
</head>
<body>
<form action="upload.php" method="POST" enctype="multipart/form-data">
<input type="file" name="audioFile"/>
<input type="submit" value="Upload Audio" name="save_audio"/>
</form>
</body>
</html>
upload.php
<?php
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 'upload ok';
}
}
?>
Note: The uploads folder is in the same path as the pages shown here.