dongzhenyin2001 2014-10-27 20:25
浏览 76
已采纳

如何在不重定向到index.php文件的情况下列出目录中的文件?

i am writing a simple script to list all the files of an external sites directory. i am using curl for this. the code i have written is below

$url="http://externalsite.com/directory/";

$ch = curl_init();

curl_setopt($ch, CURLOPT_AUTOREFERER, FALSE);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FTPLISTONLY, TRUE);

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE);       

$data = curl_exec($ch);
curl_close($ch);

echo $data;

but when i execute the above code it is showing the contents of the index.php file which is in the directory. how to list all the files in the directory without redirecting it to index.php file ?

  • 写回答

1条回答 默认 最新

  • dongmei9020 2014-10-27 20:32
    关注

    The behavior is not controlled by the client, it is up to the server to decide what will be served. For example, depending on the server configuration, the default file that will be served by apache is index.php, index.html, or the contents of the directory if none of the above is present there and the Indexes option is not disabled.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?