<?php
    $con=mysql_connect("localhost","root","");
        if(!$con)
        {
        die('Could Not Connect:'.mysql_error());
        } 
    mysql_select_db("tcs",$con);
    $upload_to = "./uploadedfiles/";
    move_uploaded_file(
        $_FILES["filename"]["tmp_name"],
        $upload_to . "/" . $_FILES["file"]["name"]
    );
    $sql="insert into employee values ('$_POST[username]','$_FILES[filename][name]')";
    if (!mysql_query($sql,$con))
      {
      die('Error: ' . mysql_error());
      }
    echo "Employee Uploaded File"."$_FILES[file][name]";  //showing uploaded file name 
    ?>
But there are three problems:
- $sql="insert into employee values('$_POST[username]','$_FILES[filename][name]')";
By '$_FILES[filename][name]' this command file name is not saving in database.
And if I try $sql="insert into employee values ('username....','$_FILES["filename"]["name"]')" then a syntax error is displayed. 
How do I send file name also in database? Please write or edit above code.
How do I add username id with this file so that it can be downloaded in the future?
- If I try the same file name from another location to store in the database (uploaded folder), then the file is still the same (only one copy after 2 times of uploading the same file name but from different locations). 
- How to download file if user wants to download it? How server will know that this file name belongs to this user? Please tell me the code for this purpose. 
 
     
     
    