Search code examples
phpftpwrapperioctl

Inappropriate ioctl for device when using ftp wrapper in php


<?php
error_reporting(E_ALL);
var_dump(scandir('ftp://user:pass@host:21/public_html/'));

Works on my localhost WAMP server but it doesn't seem to work on my school server (Apache/2.4.6, PHP/5.4.24 on Slackware)

It throws the following error:

root@darkstar:/var/www/codedit/www# php test.php
PHP Warning:  scandir(ftp://[email protected]/public_html/): failed to open dir: not implemented in /hdd/hdd11/www/codedit/www/test.php on line 4
PHP Warning:  scandir(): (errno 25): Inappropriate ioctl for device in /hdd/hdd11/www/codedit/www/test.php on line 4
bool(false)

However, I successfully log into the ftp server when using the built-in PHP functions (ftp_connect,ftp_login,etc)

Any ideas would be much appreciated.


Solution

  • To answer my own question: After hours of thinking about what may cause this issue, it turned out to be the with-curlwrappers PHP option. It is removed from PHP as of version 5.5 so upgrading the PHP version or recompiling the PHP with curlwrappers disabled solves the problem. I hope this answer will be of some use. :)