Go Back   SitePoint Forums > Forum Index > Program Your Site > PHP
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
Reply
 
Thread Tools Display Modes
Old Jun 8, 2003, 15:44   #1
pregaming
SitePoint Enthusiast
 
Join Date: Apr 2003
Location: New York
Posts: 86
Opening an anon ftp directory using readdir()

I just moved all my downloads from http to ftp and I was having some trouble modifying my scripts..

What I had before was:
PHP Code:

$dir="./ghdl/Files346tlm/file";

$sizedir = $dir;
$dir = opendir("$dir");
  while(
$item = readdir($dir)){ ...
which was http://www.pregaming.com/ghdl/...

but now its ftp so I have to change the dir.

Web location: ftp://pregaming.com/pub/....
Server location: /anon_ftp/pub...

I tried both

PHP Code:

$dir=".anon_ftp/pub/..."; 

and

PHP Code:

$dir="ftp://pregaming.com/pub/..."; 

but both didn't work

(got the error:
Code:
 Warning: OpenDir: No such file or directory (errno 2) 
Warning: readdir(): supplied argument is not a valid Directory resource
)

Any ideas? Thanks
pregaming is offline   Reply With Quote
Old Jun 9, 2003, 04:22   #2
Cam
********* Wizard
silver trophy
 
Cam's Avatar
 
Join Date: Aug 2002
Location: Burpengary, Australia
Posts: 4,601
Have a look at the FTP functions in the PHP manual.
Cam is offline   Reply With Quote
Old Jun 9, 2003, 10:53   #3
pregaming
SitePoint Enthusiast
 
Join Date: Apr 2003
Location: New York
Posts: 86
Quote:
Originally Posted by DJ P@CkMaN
Have a look at the FTP functions in the PHP manual.
So I can't use opendir() and readdir() when using ftp?
pregaming is offline   Reply With Quote
Old Jun 10, 2003, 00:05   #4
Cam
********* Wizard
silver trophy
 
Cam's Avatar
 
Join Date: Aug 2002
Location: Burpengary, Australia
Posts: 4,601
No, because FTP is it's own protocol, readdir() only works on the local filesystem.
Cam is offline   Reply With Quote
Old Jun 10, 2003, 09:21   #5
firepages
sitepoint wombat
 
firepages's Avatar
 
Join Date: Jul 2000
Location: Perth Australia
Posts: 1,722
if fopen wrappers are enabled then eg readfile('ftp://userassword@yourdomain.com/') should work ?
firepages is offline   Reply With Quote
Old Jun 10, 2003, 15:57   #6
Cam
********* Wizard
silver trophy
 
Cam's Avatar
 
Join Date: Aug 2002
Location: Burpengary, Australia
Posts: 4,601
Well, that's too advanced for me
Cam is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread | Next Thread »

Thread Tools
Display Modes

 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 13:13.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved