php filesystem function, rename() function renames a file or directory. If successful, the function returns true. If it fails, false is returned.
Statement: rename(oldname, newname,context)
Parameter description
oldname is required, specifies the file or directory to be renamed.
newname is required, specifies the new name of the file or directory.
context is required and specifies the environment of the file handle. context is a set of options that can modify the behavior of the stream.
Note: Before PHP 4.3.3, rename() cannot rename across disk partitions in *nix-based systems File.
Note: The encapsulation protocol used in oldname must match the one used in newname.
Note: Support for context was added in php 5.0.0.
oldpath ----The original path of the file or directory, $newpath ----The new definition path, then rename($oldpath,$newpath) can complete the file / Directory moving operation, after my testing, both win32 and unix php4 versions support this function.
In addition, it seems that the win32 version of php4 has canceled the unlink() function, so you can also use the rename() function to complete it. Deletion operations, for example:
$path ---- file or directory path
$tmp ---- tmp directory (/tmp)
Use rename($path,$tmp) to move the file to the tmp directory.