How can we move the one file from one folder to another folder without copy function in PHP. In php copy function used to copy the file from one folder to another folder. But in my case I don't use copy function for move the file from folder to another folder.
You can try and make use of php rename function. It will move the file if a new directory was specified in the new move to
filename. Just ensure that the permission are correct when moving and creating new folders and files.
rename("path1/file.txt", "path2/file.txt");
Attempts to rename oldname to newname, moving it between directories if necessary. If newname exists, it will be overwritten.
If you do not want use PHP copy()
function for some reason, you can do this like:
system('cp /path/to/src_file /path/to/dst_file');
for *nix systems, and
system('copy /path/to/src_file /path/to/dst_file');
for Windows
Suggest using rename(). http://php.net/manual/en/function.rename.php
rename('/dir1/old_dir/old_name.txt','/dir1/new_dir/zzz_name.bak');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.