Welcome to Dream.In.Code
Become a PHP Expert!

Join 150,175 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 2,211 people online right now. Registration is fast and FREE... Join Now!




php ftp error

 
Reply to this topicStart new topic

php ftp error

musya
25 Aug, 2008 - 10:53 PM
Post #1

D.I.C Regular
Group Icon

Joined: 25 Apr, 2007
Posts: 296



Thanked: 1 times
Dream Kudos: 50
My Contributions
so I'm working with the php ftp functions, and I have it working to browse through dir's it shows the first root directories of the connection, when i go one directory in to it, all goes well, but when i attempt to go 2 directories into it, it doesnt show anything, i thought at first you would need to go 1 dir then 2 dir again, but still nothing,

here is a bit of my code, its of any help, has anyone had this similar issue before?
php

if($path != null)
{
$sep = explode('/', $path);
foreach($sep as $var)
{
$buff = ftp_nlist($conn_id, $var);
}
}
else
{
$buff = ftp_nlist($conn_id, $c_dir);
}

here it checks for a path if their is one it chdir to the first dir then to the 2 and so on, and if no path then just to the chosen dir, and i had also tryed chdir to just the selected one, like so
php

$buff = ftp_nlist($conn_id, $c_dir);

But none show the contents of the second directory, i even checked the permissions of the directories...all good. so any help would be greatly appreciated.

Thank you,
Musya

This post has been edited by musya: 25 Aug, 2008 - 10:55 PM
User is offlineProfile CardPM
+Quote Post

musya
RE: Php Ftp Error
26 Aug, 2008 - 05:14 PM
Post #2

D.I.C Regular
Group Icon

Joined: 25 Apr, 2007
Posts: 296



Thanked: 1 times
Dream Kudos: 50
My Contributions
Umm, sorry to bug but I'm really stuck on this, any help would be loved.... biggrin.gif
User is offlineProfile CardPM
+Quote Post

AdaHacker
RE: Php Ftp Error
26 Aug, 2008 - 05:45 PM
Post #3

D.I.C Head
**

Joined: 17 Jun, 2008
Posts: 194



Thanked: 33 times
My Contributions
QUOTE(musya @ 26 Aug, 2008 - 08:14 PM) *

Umm, sorry to bug but I'm really stuck on this, any help would be loved.... biggrin.gif

Seriously? Bumping your post after only 6 hours? Have a little patience, for crying out loud.

Now, as to your question, take a closer look at your code here:
php

$sep = explode('/', $path);
foreach($sep as $var)
{
$buff = ftp_nlist($conn_id, $var);
}

This is taking a back, splitting it on the slashes, and then running an ftp_nlist() on each component of it. So you're trying to list fragments of a full path. Not only will this not work, it doesn't even make sense. You need to pass ftp_nlist() a full path. If you want to break the path down and list each component, then you have to break the path down as you did and then build it back up. That's easily done by appending the current component to a string with each iteration and listing that.
User is offlineProfile CardPM
+Quote Post

musya
RE: Php Ftp Error
26 Aug, 2008 - 08:50 PM
Post #4

D.I.C Regular
Group Icon

Joined: 25 Apr, 2007
Posts: 296



Thanked: 1 times
Dream Kudos: 50
My Contributions
Thanks for the reply, I'll try it out, as for the bumping it was 18 hours, and yes maybe i should have waited a little bit longer. but thank you for the help ill try it and let you know..

Musya
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 03:32AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month