Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

read files from remote ftp server

Status
Not open for further replies.

hinchdog

Programmer
Feb 14, 2001
380
US
is it possible to read a list of text files from a remote server (an FTP server actually). i want someone to be able to see the file list and then click on the name to display the text file as html. is this possible?
 
If you PHP build was built with the FTP functions then this should be no problems. Check out the FTP functions at

to list the files use the ftp_nlist function (after you connect of course) and ftp_fget to read the file.

Hope this helps :)
 
If your build was not compiled with the --enable-ftp, then you will need to recompile with the --enable-ftp switch to use the FTP functions. The only other option that you might be able to do is to write external scripts (not PHP) that perform the necessary FTP commands and use then you can use PHP's system() function to call these scripts and display their output. But that (in my opinion) would be more hassle than recompiling PHP.
 
i'm extemely new to php, so bear with me. how exactly do i recompile php -- isn't this something my webhost has to do?
 
If you are not running your own server, then it would be something that your webhost would have to do.

Most of the webhosts that I know probably will not recompile their PHP, unless you are paying them for a dedicated server (like Rackspace ... usually $300 plus a month).

You can always tell what options were compiled into your build by running this code:

<?
phpinfo();
?>

look for a line that says
FTP Support enables (or disabled).

If you are running your own server, then it will depend on you OS on how your compile your build.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top