I am trying to upload a song to a database using PHP, just like soundcloud web. But it gives me error
Notice: Undefined index: file in C:\Xampp\htdocs\aksongs\upload.php on line 25
Notice: Undefined index: file in C:\Xampp\htdocs\aksongs\upload.php on line 26
Here is the code of file
<?php
include_once 'connection.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>AK music</title>
<link rel="stylesheet" href="main.css" href="main.js" >
</head>
<body>
<form enctype="multipart/form-data" action="upload.php" method="POST">
Please choose a file: <input name="file" type="file" /><br />
<input type="submit" value="submit" />
</form>
<?php
$name = $_FILES['file']['name'];
$tmp_name = $_FILES['file']['tmp_name'];
if(isset($name)){
if(!empty($name)){
$location = 'aksongs/upload';
if(move_uploaded_file($tmp_name,$location.$name)){
echo 'uploaded';
}
}else{
echo 'Please choose a file';
}
}
?>
</body>
</html>