I am getting some errors trying to upload a file to an directory. These are the errors:
Notice: Undefined index: sPic in C:\wamp\www\uniqueminecraftservers\upload\upload.php on line 8
Notice: Undefined index: sPic in C:\wamp\www\uniqueminecraftservers\upload\upload.php on line 13
Notice: Undefined index: sPic in C:\wamp\www\uniqueminecraftservers\upload\upload.php on line 23
Here is my PHP:
<?php
$name = htmlspecialchars($_POST['sName']);
$ip = htmlspecialchars($_POST['sIp']);
$type = $_POST['sType'];
$port = htmlspecialchars($_POST['sPort']);
$website = htmlspecialchars($_POST['sWeb']);
$video = htmlspecialchars($_POST['sVideo']);
$pic = ($_FILES['sPic']['name']); // line 8
$desc = htmlspecialchars($_POST['sDesc']);
$target = "/uniqueminecraftservers/slist/banners/";
$target = $target . basename( $_FILES['sPic']['name']); // line 13
// Connects to your Database
mysql_connect("localhost", "root", "") or die(mysql_error()) ;
mysql_select_db("slist") or die(mysql_error()) ;
//Writes the information to the database
mysql_query("INSERT INTO `postdata` VALUES ('$name', '$ip', '$port', '$type', '$website', '$video', '$desc')") ;
//Writes the photo to the server
if(move_uploaded_file($_FILES['sPic']['tmp_name'], $target)) // line 23
{
//Tells you if its all ok
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory";
}
else {
//Gives and error if its not
echo "Sorry, there was a problem uploading your file.";
}
?>
I have tried evrything I can find online while searching for the past 2 hours. I CANNOT FIGURE OUT HOW TO FIX THIS.
Note: Running on WAMP with PHP 5.4.3