Php 符号链接目录

Php 符号链接目录,php,download,symlink,Php,Download,Symlink,我能看一下我的符号链接吗 我试图从一个目录下载一个文件,而该文件实际上存在于另一个目录中 我在单独的子目录中得到了实际的文件和符号链接,但它们都位于公共html中(都可以通过web访问) 我已经通过直接访问文件验证了我(共享Linux)服务器上的文件和文件位置 正在创建链接(我使用了readlink、is_link和linkinfo),我可以在FTP中看到它 我相信我可能只是对目录结构有误解 我把文件放在这里:./testdownload/ 我把符号链接放在这里:./testDelivery/

我能看一下我的符号链接吗

我试图从一个目录下载一个文件,而该文件实际上存在于另一个目录中

我在单独的子目录中得到了实际的文件和符号链接,但它们都位于公共html中(都可以通过web访问)

我已经通过直接访问文件验证了我(共享Linux)服务器上的文件和文件位置

正在创建链接(我使用了readlink、is_link和linkinfo),我可以在FTP中看到它

我相信我可能只是对目录结构有误解

我把文件放在这里:./testdownload/

我把符号链接放在这里:./testDelivery/

<?php
$fileName = "testfiledownload.zip";//Name of File
$fileRepository = "./testdownload/";//Where the actual file lives
$downloadDirectory = "./testDelivery/";//Where the symlink lives
unlink($downloadDirectory . $fileName);  // Deletes any previously exsisting symlink (required)
symlink($fileRepository . $fileName, $downloadDirectory . $fileName); 
$checkLink = ($downloadDirectory . $fileName);
if (is_link($checkLink))
{
    echo ("<br>Symlink reads: " .readlink($checkLink) . "<br>");
    echo ("<br>LinkeInfo reads: " . linkinfo($checkLink));
}
?>
<p><a href="<?php echo ("/testDelivery/" . $fileName); ?>"</a>SymLink</p>
<p><a href="<?php echo ("/testdownload/" . $fileName); ?>"</a>regular link</p>

符号链接

常规链接

我觉得一切都很好…但链接不起作用。 帮忙

最后,我将把源数据放在公共区域之外…这只是为了测试

(我正试图找到一个更好的下载解决方案,而不是将fread分块,因为fread因连接不良而失败。(200-400MB文件))

我的问题(似乎)是没有为符号链接提供绝对路径

我已将下面的绝对路径添加到上面相同的代码中,以提供一个工作副本:

<?php
$absolutepath = ( $_SERVER['DOCUMENT_ROOT']);
$fileName = "testfiledownload.zip";//Name of File
$fileRepository = "/testdownload/";//Where the actual file lives
$downloadDirectory = "/testDelivery/";//Where the symlink lives
unlink($absolutepath .$downloadDirectory . $fileName);  // Deletes any previously exsisting symlink (required)
symlink($absolutepath . $fileRepository . $fileName, $absolutepath. $downloadDirectory . $fileName); 
$checkLink = ($absolutepath . $downloadDirectory . $fileName);
if (is_link($checkLink))
{
    echo ("<br>Symlink reads: " .readlink($checkLink) . "<br>");
    echo ("<br>LinkeInfo reads: " . linkinfo($checkLink));
}
?>
<p><a href="<?php echo ("/testDelivery/" . $fileName); ?>"</a>SymLink</p>
<p><a href="<?php echo ("/testdownload/" . $fileName); ?>"</a>regular link</p>

符号链接

常规链接

这篇原创文章是重复的(尽管我直到现在才看到)
(然而,针对这个问题给出的大多数答案都是错误的——但最初的海报发现了这一点,这对我也很有用)

你在使用Apache吗?如果是,设置了吗?是的,设置了选项+FollowSymLinks这让我很困惑。我无法判断我的语法(在上面的示例中)是否错误,或者(不知何故)符号链接是否不起作用。上面的代码一定有问题。我已经在三台(全部共享)服务器上试用过,但在每台服务器上都失败了。它生成了404错误…尽管我可以在FTP应用程序中看到符号链接。