PDA

View Full Version : PHP FTP Access



y2khines
12-02-2006, 11:45 AM
Hello all..

I'm switching to bluehost and can't get FTP via PHP access to work. PHPINFO shows that FTP is enabled...

./configure' '--enable-pic' '--with-libdir=lib64' '--prefix=/usr' '--with-xml' '--enable-bcmath' '--enable-calendar' '--with-curl' '--with-dom' '--with-dom-xslt' '--with-dom-exslt' '--enable-exif' '--enable-ftp' '--with-gd' '--with-jpeg-dir=/usr/local' '--with-png-dir=/usr' '--with-xpm-dir=/usr/X11R6' '--with-gettext' '--with-iconv' '--with-imap=/usr/local/imap-2004g' '--enable-mbstring' '--enable-mbstr-enc-trans' '--enable-mbregex' '--with-mcrypt' '--with-mhash' '--enable-magic-quotes' '--with-mysqli' '--with-mysql=/usr' '--with-openssl' '--enable-discard-path' '--with-pdflib' '--with-pear' '--with-pgsql=/usr' '--with-pspell' '--enable-xslt' '--with-xslt-sablot' '--enable-sockets' '--enable-track-vars' '--with-ttf' '--with-freetype-dir=/usr' '--enable-gd-native-ttf' '--with-zlib'

... But I can't get my main script to connect to my remote FTP server. Here's a simple script using curl, and it also fails to connect. My old webhost account with my previous provider is still active, and this script along with the main script work fine.


<?
// create a new curl resource
$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "ftp://uname:password@13.13.13.13/foldername/version.inf");
curl_setopt($ch, CURLOPT_HEADER, 1);

// grab URL and pass it to the browser
curl_exec($ch);

// close curl resource, and free up system resources
if (curl_errno($ch))
{
echo curl_error($ch);
}
else
{
curl_close($ch);
}
?>

Any ideas?
Thanks.
CH

indy2kro
12-02-2006, 12:23 PM
"--enable-ftp" means that it has been compiled with ftp functions enabled. Basically this means you can put a script on your account to connect using ftp to ANOTHER server ..

See http://www.php.net/ftp for more informations on this.

y2khines
12-02-2006, 12:52 PM
"--enable-ftp" means that it has been compiled with ftp functions enabled. Basically this means you can put a script on your account to connect using ftp to ANOTHER server ..

See http://www.php.net/ftp for more informations on this.

Well yeah. That's my point. I know it's enabled, but it isn't working. With my previous provider this simple test script works fine. If FTP wasn't enabled then I would have gobs of PHP errors from my main script. The only error I have now is "cannot connect to <IP>".

Does anyone know what else will cause this to fail? Is it being blocked by BH somehow?

TIA.
CH

y2khines
12-02-2006, 01:29 PM
Turns I didn't have a static IP assigned to my account. This was needed to establish outbound connections.

All is good now.

CH

indy2kro
12-03-2006, 06:18 AM
This might not be off much help since you found out the cause, but in order to use CURL functions you need '--with-curl' (which is also active), not the ftp one.

y2khines
12-07-2006, 11:10 PM
I know.. ftp and curl both had the same issue. My accound didn't have access to establish outbound connections.

Now that I have a static IP, all is good.

Mazzic
12-08-2006, 05:14 PM
Not entirely correct, you could actually establish outbound connections but only on port 80 or 443, the standard http/https ports.