I am having a strange problem with my php. Whenever I try to move a file using rename (), not only the file does not move, but the directory into which it must be copied is deleted along with all the files inside it. Source:
rename('temp.odt', 'tmp/report.odt');
but I already tried other path separators like
rename('temp.odt', 'tmp\report.odt'); rename('temp.odt', 'tmp\\report.odt'); rename('temp.odt', 'tmp' . DIRECTORY_SEPARATOR . 'report.odt'); rename('C:\wamp\www\zaiko\temp.odt', 'C:\wamp\www\zaiko\tmp\report.odt');
all to no avail. The code comes from a third-party module that is used in the system I'm working on.
Points are well checked:
- The temp.odt file exists in the current directory;
- The directory 'tmp' exists and there are several files in it. Also it is not readable only.
- The target file does not exist yet (the actual file name has a timestamp, I reduced it here for simplicity)
After rename () is run, the βtemp.odtβ file remains untouched at its original location, and the βtmpβ folder has disappeared , as well as everything inside it. The following warning is issued:
(!) Warning: rename (temp.odt, tmp \ report.odt) [function.rename]: the system could not find the specified path *. (code: 3) in C: \ wamp \ www \ zaiko \ modules \ mod_deliver.php on line 192
* Translated from Portuguese
Launch: Apache 2.2.17 with PHP 5.3.5 on Windows XP with NTFS
Editing:
Just found the cause of the problem. It turns out that the module used by the application uses, in turn, a compression library; this library uses a temporary folder with the same name as the application used by the application.
It should use some kind of cache, which explains why the error did not appear 100%.
The problem is resolved by changing the name of the "tmp" folder to something else.
Thank you all for your time and it is a pity to bother you with such a stupid thing that, as it turned out, had absolutely nothing to do with my initial assumption and, therefore, with the question formulated.