Upload File to a PHP server using C#

 <?php
//check whether the folder the exists
if(!(file_exists('Data')))
{
  //create the folder
  mkdir('Data');
  //give permission to the folder
  chmod('Data', 0777);
}

//check whether the file exists
if (file_exists('Data/'. $_FILES["file"]["name"]))
{
   echo $_FILES["file"]["name"] . " is success ";
   move_uploaded_file($_FILES["file"]["tmp_name"],'Data/'. $_FILES["file"]["name"]);
}
?>

//Server.cs
public static void UploadToCloud(string filename = book.xml)
{
    WebClient myWebClient = new WebClient();
    
    try
    {
        byte[] responseArray = myWebClient.UploadFile( Constants.XML_SERVER_PATH + "fileupload.php", "POST", filename);
        
        // Decode and display the response.
        Console.WriteLine("\nResponse Received.The contents of the file uploaded is:\n{0}",
            System.Text.Encoding.ASCII.GetString(responseArray));
    }
    catch (Exception e)
    {
        Console.WriteLine("{0} Exception", e);
    }        
}