I'm trying to rename a temporary file I've created but it doesn't work. Says the file doesn't exist. When I do a file_exists() on the file, it also says it doesn't exist. Yet I can see the file on the server....
//create temp file
$tmp = time().".xml";
$handle = fopen($tmp, "w");
fwrite($handle, "data goes here");
//rename temp file
your code worked fine for me. Result was a file called data.xml with "data goes here" as the content.
Are you getting an error message?
after refreshing the script an error was produced because data.xml already existed at this stage. Is this the error you got?
No such file or directory
That's the error I'm getting on the rename
You get the already exists error in windows.
Tried your code again, on my linux host and it worked fine.
Each time I executed the script it overwrote data.xml
Any ideas why it doesn't work on mine then?
im going to guess because the code you have posted, is not the code you are actually running.
maybe you dont realize it, or maybe you have ommited some code that you felt was irrelevant.
in any case, try the code, exactly as you have posted it. make a new script for it.
Yup, you're right.
I'm an idiot. All working now.