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.

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

报告相同问题?

悬赏问题

  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元