my code works successfully . but i dont know how to save the .csv file to a seperate directory D:\xampp\htdocs\works\_try\export\_files. and my file resides in D:\xampp\htdocs\works\_try\master\file.php my code given below .

```
<?php
$server='localhost';
$login='root';
$password='';
$db='tc';
$filename='export1.csv';
$conn=mysqli_connect($server, $login, $password,$db);
$fp = fopen('export_files/../'.$filename, "w");
$sql="SELECT * FROM student";
$res = mysqli_query($conn,$sql);
$row = mysqli_fetch_assoc($res);
$line = "";
$comma = "";
foreach($row as $name => $value) {
$line .= $comma . '"' . str_replace('"', '""', $name) . '"';
$comma = ",";
}
$line .= "\n";
fputs($fp, $line);
mysqli_data_seek($res, 0);
while($row = mysqli_fetch_assoc($res)) {

$line = "";
$comma = "";
foreach($row as $value) {
    $line .= $comma . '"' . str_replace('"', '""', $value) . '"';
    $comma = ",";
}
$line .= "\n";
fputs($fp, $line);
}
fclose($fp);
echo " success :)  !!!!!!!!!!!!!!!!!!!!!!   Please check the file ";
?> 

```

i should save the .csv file in folder\_name export\_files and my php code runs in the folder\_name master.my problem is csv file getting saved in folder\_name master itself.where file should save in export\_files.