Reputation: 1781
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..
Upvotes: 1
Views: 9512
Reputation: 61
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()
Upvotes: 0
Reputation: 7895
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);
Upvotes: 1