14

For some reason the ftp_connect() function doesn't work, when I try to used it it ends with a fatal error stating that this function is undefined... Surprisingly I can still use a ftp client or use an ftp connection through the Terminal. How may I solve this problem ?

I run on Mountain Lion et I've got the 5.3 php version - I reinstalled it once hoping this would solve my problem.

7 Answers 7

18

Check PHP FTP installation manual

On PHP 7, You can enable it by adding this line to the php.ini file.

extension=php_ftp.dll

On PHP 8+ enable this line in php.ini:

extension=ftp
12

I ran into the same issue. After I checked this one setting, it worked just fine.

enter image description here

8

Sounds like your PHP was not installed with --enable-ftp or that the ftp module is disabled in your php.ini.

To check if ftp is enabled, create a page like this and browse to it:

<?php
phpinfo();
?>

Look for "ftp support", it should be marked "enabled".

7
  • 1
    I don't even find "ftp support", does that mean that it's not installed ? Aug 27, 2013 at 21:48
  • Yes, actually it would never say "disabled".
    – Menthos
    Aug 27, 2013 at 22:13
  • I've gone through a new installation of php (5.4) and I now have the line FTP support enabled, still I've got that error : Fatal error: Call to undefined function ftp_connect() in ... Aug 28, 2013 at 11:25
  • I don't know what could be wrong, my PHP 5.3 works with FTP on Mountain Lion with no particular setup. It may be a stupid question, but have you restarted Apache after reinstalling PHP? (sudo /usr/sbin/apachectl restart)
    – Menthos
    Aug 28, 2013 at 11:57
  • Yes I restarted apache. The error doesn't seem to come from the php itself, maybe it's because of the deamons agent, how may I check that ? Aug 28, 2013 at 16:51
0

I found that (at least for higher versions of PHP), that Luboš Turek's answer is mostly correct. On Windows, at least, you don't need (or want) the ".dll" suffix.

What is very odd is that the PHP.INI default configuration file doesn't even include a commented out line stating:

;extension=php_ftp

So, as Luboš said, adding:

extension=php_ftp

to the INI will work. That said, check your ext folder to make sure the FTP extension is there.

0

I came here looking for an answer and fixed mine by changing the setting in php.ini as below. I removed the leading semicolon on the ftp extension line (at the bottom).

; - Many DLL files are located in the extensions/ (PHP 4) or ext/ (PHP 5+)
; extension folders as well as the separate PECL DLL download (PHP 5+).
; Be sure to appropriately set the extension_dir directive.
;
extension=bz2
extension=curl
;extension=dba
extension=com_dotnet
;extension=enchant
extension=fileinfo
extension=ftp
-1

Guys I find the Solution, For me I had PHP 5 and now I have PHP 7. I get this error. Do this: Open PHP.INI Search for : allow_url_include = Off Change Off to ON: Like this: allow_url_include = On

Restart all Service on Wamp server

-2

I had the same problem, i fix it disabling the antivirus or add the apache server to the exception.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.