Good afternoon guys, I'm trying to create a text file with the client IP, so let's say the server will create a file execute X action, send the file to download to the client, then deletes the server. I'm just missing out on how to create the file with the client's ip number, my intent is that if I set a default file name, and multi-paged access, when I generate the file they do not conflict, maybe I have another way of doing this ...
<?php
$arquivo = fopen("num_ip", "w");
$texto = "Conteúdo do cliente aqui";
fwrite($arquivo, $texto);
fclose($arquivo);
function download( $path, $fileName = '' )
{
if( $fileName == '' )
{
$fileName = basename( $path );
}
header("Content-Type: application/force-download");
header("Content-type: application/octet-stream;");
header("Content-Length: " . filesize( $path ) );
header("Content-disposition: attachment; filename=" . $fileName );
header("Pragma: no-cache");
header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
header("Expires: 0");
readfile( $path );
flush();
}
download( 'num_ip.txt', 'arquivo.txt' );
$arquivo = "num_ip.txt";
(!unlink($arquivo))
?>