Skip to main content

my way is using tempnam

$file = tempnam(sys_get_temp_dir(), 'prefix'); file_put_contents($file.'.extension', $data); { //use your file } unlink($file);//to delete an empty file that tempnam creates unlink($file.'.extension');//to delete your file 

my way

$file = tempnam(sys_get_temp_dir(), 'prefix'); file_put_contents($file.'.extension', $data); { //use your file } unlink($file);//to delete an empty file that tempnam creates unlink($file.'.extension');//to delete your file 

my way is using tempnam

$file = tempnam(sys_get_temp_dir(), 'prefix'); file_put_contents($file.'.extension', $data); { //use your file } unlink($file);//to delete an empty file that tempnam creates unlink($file.'.extension');//to delete your file 
Source Link

my way

$file = tempnam(sys_get_temp_dir(), 'prefix'); file_put_contents($file.'.extension', $data); { //use your file } unlink($file);//to delete an empty file that tempnam creates unlink($file.'.extension');//to delete your file