I'm unable to understand the sense of this line
$domain = ($_SERVER['HTTP_HOST'] != 'localhost') ? $_SERVER['HTTP_HOST'] : false;
You can directly do this :
setcookie('imgName', $_FILES['file']['name'], time()+3600, '/', $_SERVER['HTTP_HOST'], false);
( I tried your code online, that is returning NULL
while this is return the right cookie name )
EDIT (for example) :
PHP CODE :
if(isset($_POST['submit']))
{
$cookie = $_FILES['img']['name'];
setcookie('myCookie',$cookie,time()+3600,'/');
foreach ($_COOKIE as $key=>$val)
{
echo $key.' is '.$val."<br>\n";
}
}
HTML CODE :
<form action="#" method="post" enctype="multipart/form-data">
<input type='file' name="img">
<input type='submit' name="submit" value="GO">
</form>