In PHP whenever someone uploads a file I want it to create a [filename.fileextension].log file that stores the IP of the person who uploaded it, I have a getip function but dont know how to create the file.
PHP:
function getip()
{
global $_SERVER;
if ($_SERVER['HTTP_X_FORWARD_FOR']) //stupid proxies! :P
{
return $_SERVER['HTTP_X_FORWARD_FOR']; //get there real ip hehe
}
else
{
return $_SERVER['REMOTE_ADDR']; //they dont use a proxy :)
}
}
PHP:
$ip = getip();
$folder = "./uploads/";
//$newfile is the name of teh file they uploaded.
$logfile = $newfile.".log";
//create file somehow on this line called the value of $logfile
$handle = fopen($folder,$logfile);
fwrite($handle,$ip);
Last edited:






