I know you can create a temporary file with tmpfile and than write to it, and close it when it is not needed anymore. But the problem I have is that I need the absolute path to the file like this:
$fh = fopen("/var/www/html/myfile.xml", 'w') or die("no no");
Just in case someone encounters exactly the same problem. I ended up doing
$fh = fopen($filepath, 'w') or die("Can't open file $name for writing temporary stuff."); fwrite($fh, $fileData); fclose($fh);
at the end when file is not needed anymore.
Before that, I generated filename like that:
$r = rand(); $filepath = "/var/www/html/someDirectory/$name.$r.xml";