hi guys,

i saw same article with my problem, but i seem dont get the solution. the code works but some notice error.

i have problem: "Notice: Undefined index:" Line: 40 // basename($_FILES['uploadedfile']['name'])

the Code:


 //This is the directory where images will be saved 
 $target = "images/"; 
 $target = $target . basename($_FILES['photo']['name']); 

 //This gets all the other information from the form 


 // Connects to your Database 
// mysql_connect("localhost", "root", "pw", "test") or die(mysql_error()) ; 
// mysql_select_db("Database_Name") or die(mysql_error()) ; 

    $con = mysqli_connect("localhost", "root", "pw", "test");
        echo "error connection" . mysqli_connect_error();

 //Writes the information to the database 
  //(id, name, email, phone, pic) did not use this
 $sql = "INSERT INTO employees VALUES ('$id', '$name', '$email', '$phone', '$pic')" ; 

 if(!mysqli_query($con, $sql))
    die('Error ' . mysqli_error());
echo "1 Data added";

 //Writes the photo to the server 
 if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) 
 //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 "<br>Sorry, there was a problem uploading your file."; }


Please help. Thanks in advance.

Recommended Answers

All 2 Replies

basename($_FILES['photo']['name']); and basename($_FILES['uploadedfile']['name']).

i think i have the answer, but i dont know if this is the correct one, i use basename( $_FILES['photo']['name']) instead of basename( $_FILES['uploadedfile']['name']). thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.