Monday 15 June 2015

curl - how to list files in a directory without redirecting to index.php file? -



curl - how to list files in a directory without redirecting to index.php file? -

i writing simple script list files of external sites directory. using curl this. code have written 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 execute above code showing contents of index.php file in directory. how list files in directory without redirecting index.php file ?

the behavior not controlled client, server decide served. example, depending on server configuration, default file served apache index.php, index.html, or contents of directory if none of above nowadays there , indexes alternative not disabled.

php curl

No comments:

Post a Comment