'csv file generate and save it in specific folder using php any one can help me

enter code here

Here generate CSV file and its download directly when submit form but i want save it in specific folder plz any one can help me ...

 <?php if(isset($_POST['submit']))                    
{
//collect form data
$name = $_POST['name'];
$address = $_POST['address'];
$mobileno = $_POST['mobileno'];
$email = $_POST['email'];

if(!isset($error)){

  $Content = "Name,Address,Mobile,Email \n";

    //set the data of the CSV
    $Content .= "$name,$address,$mobileno,$email\n";

    //set the file name and create CSV file
    $FileName = $name."-".date("d-m-y-h:i:s").".csv";
    header('Content-Type: application/csv'); 
    header('Content-Disposition: attachment; filename="' . $FileName . '"'); 
    echo $Content;
    exit();
  }
 }

 //if their are errors display them
if(isset($error)){
foreach($error as $error){
    echo '<p style="color:#ff0000">$error</p>';
   }
 }
?>
php


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source