Php rename() 无法在 unix 上重命名目录

发布于 2024-10-07 02:14:48 字数 698 浏览 1 评论 0原文

我目前正在使用 php 构建一个画廊 Web 应用程序。我目前正在 Windows 上进行开发,但部署服务器正在运行 Unix。

每个画廊都有自己的文件夹,画廊的名称从中派生(即,如果文件夹是“nature”,那将是画廊的名称。

现在,当我尝试重命名画廊时,例如,我做

rename("img/old_gallery","img/new_gallery"); 
//where img is a folder relative to this php script (rename.php)

它在 windows 下完美运行,但在 unix 下,我收到以下错误:


警告:重命名(img/old_gallery,img/products/new_gallery)[function.rename]:~server_name~/public_html/rename.php中没有这样的文件或目录第 5 行

我想可能是下划线,并尝试了“新”和“旧”等名称,结果仍然相同,在 Windows 上有效,但在服务器上不行。任何人都知道可能是什么问题吗?

附:如果重要的话,我正在使用最新的 Windows xampp,带有 php 5.3,而服务器安装了 php 5.29。这可能是问题的根源吗?

谢谢 :)

I am currently building a gallery web application using php. I am currently developping on windows but the deployment server is running unix.

Each gallery will have its own folder, from which the name of the gallery is derived (ie if the folder is "nature", that will be the gallery's name.

Now, when i try to rename a gallery, say for eg, i do

rename("img/old_gallery","img/new_gallery"); 
//where img is a folder relative to this php script (rename.php)

it works under perfectly under windows. Under unix though, i get the following error:

Warning: rename(img/old_gallery ,img/products/new_gallery) [function.rename]: No such file or directory in ~server_name~/public_html/rename.php on line 5

I thought maybe its the underscore, and tried names like "new" and "old", still same result, works on windows, but on the server doesn't. Anyone has any idea of what could be the problem?

ps. if it matters, i am using the latest xampp for windows, with php 5.3, whereas the server has php 5.29 installed. could it be the source of the problem?

thanks :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

终遇你 2024-10-14 02:14:48

由于某种原因,您的错误消息在“img/old_gallery”之后还有一个空格;那是应该存在的吗?您确定您不是意外地尝试删除“img/old_gallery”(注意空格)吗?

Your error message also has a space after "img/old_gallery" for some reason; is that meant to be there? Are you sure you're not accidentally trying to delete "img/old_gallery " (note the space) instead?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文