PHP符号链接到子目录

PHP符号链接到子目录,php,Php,我试图用PHP创建一个符号链接,指定原始路径和链接路径 我的道路是: /tx/file.jpg /sym.php 这是代码: symlink("tx/file.jpg","tx/link.jpg"); 它不工作,也不会在日志中给我错误,它只是不创建符号链接。 我甚至尝试过使用: symlink(getcwd() . "/tx/file.jpg", getcwd() . "/tx/link.jpg"); 没有运气 如果我将脚本移动到/tx/目录并运行: symlink("file.jpg",

我试图用PHP创建一个符号链接,指定原始路径和链接路径

我的道路是:

/tx/file.jpg
/sym.php
这是代码:

symlink("tx/file.jpg","tx/link.jpg");
它不工作,也不会在日志中给我错误,它只是不创建符号链接。
我甚至尝试过使用:

symlink(getcwd() . "/tx/file.jpg", getcwd() . "/tx/link.jpg");
没有运气

如果我将脚本移动到/tx/目录并运行:

symlink("file.jpg","link.jpg");
它起作用了。

为什么?我怎样才能修好它?我在CentOS 5服务器上。

符号链接的路径相对于符号链接所在的目录,而不是当前工作目录!因此,您正在创建的链接是指您所称的
tx/tx/file.jpg
,它并不存在。您需要将其创建为:

symlink("file.jpg", "tx/link.jpg");