Why do the permissions need to be so lax? This is a temporary file that will only be used by this process. Also time() is not safe to use on a busy server. You might want to use tempnam() instead to generate a safely named temporary file.