1
votes

I am trying to upload a file using the FTP class in CodeIgniter. For that I have written the following:

        $this->load->library('ftp');

        $config['hostname'] = '127.0.0.1';
        $config['username'] = 'localftp';
        $config['password'] = '';
        $config['debug'] = TRUE;

        $this->ftp->connect($config);

        $this->ftp->upload($_FILES['book_file']['tmp_name'], asset_url()."books/" . $_FILES['book_file']['name'], "ascii", 0775);

        $this->ftp->close();

but it is showing me :

Unable to upload the specified file. Please check your path.

I am using XAMPP FileZilla to connect to my FTP host. For that I have created the user localftp with no password. And this user has all the permissions on the host.

and this is my local XAMPP server logging:

  (000016)24-Dec-13 23:27:05 PM - (not logged in) (127.0.0.1)> Connected, sending welcome message...
  (000016)24-Dec-13 23:27:05 PM - (not logged in) (127.0.0.1)> 220-FileZilla Server version 0.9.41 beta
  (000016)24-Dec-13 23:27:05 PM - (not logged in) (127.0.0.1)> 220-written by Tim Kosse ([email protected])
  (000016)24-Dec-13 23:27:05 PM - (not logged in) (127.0.0.1)> 220 Please visit http://sourceforge.net/projects/filezilla/
  (000016)24-Dec-13 23:27:05 PM - (not logged in) (127.0.0.1)> USER localftp
  (000016)24-Dec-13 23:27:05 PM - (not logged in) (127.0.0.1)> 331 Password required for localftp
  (000016)24-Dec-13 23:27:05 PM - (not logged in) (127.0.0.1)> PASS
  (000016)24-Dec-13 23:27:05 PM - localftp (127.0.0.1)> 230 Logged on
  (000016)24-Dec-13 23:27:05 PM - localftp (127.0.0.1)> PASV
  (000016)24-Dec-13 23:27:05 PM - localftp (127.0.0.1)> 227 Entering Passive Mode    (127,0,0,1,205,219)
  (000016)24-Dec-13 23:27:05 PM - localftp (127.0.0.1)> TYPE A
  (000016)24-Dec-13 23:27:05 PM - localftp (127.0.0.1)> 200 Type set to A
  (000016)24-Dec-13 23:27:05 PM - localftp (127.0.0.1)> STOR   http://localhost/International/public/books/ftpupload.pdf
  (000016)24-Dec-13 23:27:05 PM - localftp (127.0.0.1)> 550 Filename invalid
  (000016)24-Dec-13 23:27:05 PM - localftp (127.0.0.1)> disconnected.

on the second last line it is saying 550 filename invalid.. I think this is my problem.. Please can any one help me out to solve this issue..

2
check this url. Same problem discussed here: ellislab.com/forums/viewthread/64329 - Kumar V
thank @kumar_v but in my case my files are found by the ftp upload method but the path is giving me issue..i am not sure about this, but it seems to be this only to me.. - Mohammed Sufian
You can see some related question located in right side in SO window. So you may get some idea from them - Kumar V
Thanks @kumar_v but just because i have not found any solution.. i had asked this question.. - Mohammed Sufian

2 Answers

1
votes

It's right there in the log:

(000016)24-Dec-13 23:27:05 PM - localftp (127.0.0.1)> STOR http://localhost/International/public/books/ftpupload.pdf

You are trying to name the file

http://localhost/International/public/books/ftpupload.pdf

which is not a valid filename.

Try removing asset_url():

$this->ftp->upload($_FILES['book_file']['tmp_name'], "books/" . $_FILES['book_file']['name'], "ascii", 0775);
0
votes

un-comment this anon_upload_enable=YES in vsftpd.conf

location etc/vsftpd

and restart ftp using > systemctl restart vsftpd

don't use asset-url()