Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

changing directory with php

$
0
0

ok, so i'm kinda new to ftp with php, i'm having difficulties with getting contents of my public_html directory (i'm using a free web hosting service)

 

 when i'm using ftp_rawlist(); to retrieve public_html content, it returns an empty array.

<?php 

$ftpServer = "usetheforce.hostei.com"; 
$ftpUser = "*"; 
$ftpPass = "*";


$conn = @ftp_connect($ftpServer) 
or die("Couldn't connect to FTP server"); 

$login = @ftp_login($conn, $ftpUser, $ftpPass);

$workingDir = ftp_pwd($conn); 
echo "Files for directory: $workingDir<br><br>"; 

$fList = @ftp_nlist($conn, $workingDir); 

if(is_array($fList)) 
{ 
$newDir = $fList[4]; // public_html

if(ftp_chdir($conn, $newDir)) 
{ 
$fList1 = ftp_rawlist($conn,$newDir); 
echo ftp_chdir($conn, $newDir);
if(is_array($fList1)) 
{ 
echo "Files for directory: $newDir<br><br>"; 
echo sizeof($fList1); 
for($i = 0; $i < sizeof($fList1); $i++) 
{ 
echo $fList1[$i] . "<br>"; 
} 
} 
else 
{ 
echo "$newDir contains no files."; 
} 
} 
else 
{ 
echo "An error
 occured while changing to $newDir or $newDir is not a directory"; } 
} 
else 
{ 
echo "$workingDir contains no files."; 
}
?> 

i've kinda isolated the problem, when i use: echo chdir($conn, "public_html") , it says: Warning: ftp_chdir() [function.ftp-chdir]: Can't change directory to public_html:. if anyone could help that would be gr8

thanks


Viewing all articles
Browse latest Browse all 13200

Trending Articles