Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试用 PHP 编写一个脚本来重置我在数据库中的 id。但我必须重命名表中具有相同 ID 的目录。
所以我尝试使用重命名功能,但我失败了。
我总是有“没有这样的文件或目录”。我尝试使用绝对或相对路径,更改 chmod,在之前使用睡眠,是的,我的文件夹存在。
所以我会知道为什么这不起作用:
rename('/uploads/photos/'.$old_id.'/', '/uploads/photos/'.$new_id.'/');
我的文件夹中有一些文件。
只需在 php 中使用 linux 命令:
exec("mv $oldname $newname");
1-修复父目录的权限。( photos) 它必须是您的 php 用户可写的。
photos
2-确保你的路径是好的/uploads/photos/...(你的第一个斜杠表示它是根目录的绝对路径)
/uploads/photos/...