This question already has an answer here:
i wrote this code some time ago and it was working perfectly but suddenly stopped working, the code cant seem to retrieve the name of the uploaded file, however if i change the name to other attributes of the file like size and type, it works perfectly fine. any help would be appreciated. thanks
i know the problem is not from the html file so i did not include. the reason im saying that is, the other file attributes like size and type works perfectly fine and as a matter of fact this same code was working fine some time ago.
<?php
try{
include("dbconnect.php");
if(isset($_POST['uploadbtn'])){
$code = $_POST['code'];
$atname = trim($_POST['artistname']);
$stittle = trim($_POST['songtittle']);
$dcription = trim($_POST['describe']);
$songtittle = filter_var($stittle,FILTER_SANITIZE_STRING);
$artistname = filter_var($atname,FILTER_SANITIZE_STRING);
$description = filter_var($dcription,FILTER_SANITIZE_STRING);
$name = $_FILES['audio']['name'];
$imname = $_FILES['image']['name'];
try{
mysqli_query($connect,"INSERT into musicfiles (music_id,uploadCode,artistName,songTittle,audio,image,fileDescription) VALUES ('','$code','$artistname','$songtittle','$name','$imname','$description')") or die("error");
echo "entered successfully";
}
catch(Exception $error){
echo "".$error;
}
}
}
catch(Exception $exe){
echo "".$exe;
}
mysqli_close($connect);
?>
</div>
$_FILES['name_of_your_input']['name']
Or check your form need to be
<form enctype="multipart/form-data" action="__URL__" method="POST">