Q: Get the directory of a downloaded file fputs() When I create a TXT file with fputs(), usually it goes into the "downloads" directory, set in the browser settings. The question is how do I get the directory path of the downloaded file.
$archivo="customers.txt";
$file = fopen($archivo,"wb");
fputs($file,$contenido);
fclose($file);
header('Content-type: text/csv; charset=ansi');
header("Content-disposition: attachment; filename=$archivo");
print $contenido; 


A: Simply put, the server is never allowed to know because the browser will never report it back.  Doing so could lead to the browser leaking private information about the user without that user's consent.
Additionally, the server cannot force a user to save a file to a specific location.  Again, this is for security reasons.  Otherwise a server could force you to save a file to your computer's startup location.
