[英]Why netbeans is hanging everytime it is trying to fetch files from a remote php site using ftp?
[英]How to fetch remote system files using PHP?
我正在做一个项目,我想从通过 LAN 连接的远程系统访问文件夹。
从那我有一个下拉列表。 当我选择远程系统盘符(例如:c:、d:)时,该文件夹中的相应文件将显示在我的系统中。
有没有这方面的教程?
我试过这个,但它只适用于本地系统,而且我无法打开相应的文件。
<html>
<head>
<title>Drive contents</title>
</head>
<body>
</body>
<?php // Php starts here
$myDirectory = opendir("C:\Dream");
$path = "c:";
// get each entry
while($entryName = readdir($myDirectory)) {
$dirArray[] = $entryName;
}
// close directory
closedir($myDirectory);
// count elements in array
$indexCount = count($dirArray);
Print ("$indexCount files<br>\n");
// sort 'em
sort($dirArray);
// print 'em
// loop through the array of files and print them all
for($index=0; $index < $indexCount; $index++) {
if (substr("$dirArray[$index]", 0, 1) != "."){ // don't list hidden files
print("<a href=\"$dirArray[$index]\">$dirArray[$index]</a>");
echo "<br>";
}
}
?>
</html>
您的 PHP 脚本在哪里运行? 为了更好地理解,你的脚本在哪里? 脚本与远程文件在同一台机器上运行还是在不同的位置?
无论如何,对于这两种情况,您应该首先检查 php safe_mode 指令是打开还是关闭,以及 open_basedir 指令的值,因为它们可以阻止您访问某些目录。
但是,如果脚本在不同的服务器上,您还应该检查远程服务器目录的权限,并验证 php.ini 中的 allow_url_fopen 指令是否设置为“On”。
尝试在<a href=...
使用file:///
前缀而不是http://
前缀
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.