We are going to discuss about how to upload files to remote server in CodeIgniter using CI’s FTP library. This library has limitations – SFTP and SSL FTP protocols are not supported, only standard FTP.
CodeIgniter’s FTP Class permits files to be transferred to a remote server. Remote files can also be moved, renamed, and deleted. The FTP class also includes a “mirroring” function that permits an entire local directory to be recreated remotely via FTP.
Lets start tutorial, first we will upload the file to same server using CodeIgniter’s upload library, then we are going to transfer file to the remote server using CodeIgniter’s FTP library.
Create upload directory in local sever to store uploaded files or images , we are going to mention this directory name in the CI’s upload library configuration.
Create destination directory in remote sever to store uploaded files or images , we are going to mention this directory name while configuring the CI’s FTP library.
Controller:
Create a controller file called Upload.php inside the application/controllers/ directory. Define a index() function and load the HTML view( upload form ).
Create a controller file called Upload.php inside the application/controllers/ directory. Define a index() function and load the HTML view( upload form ).
Once upload form is submitted, we will upload the file to the local server and after that we are connecting to the remote server via FTP and uploading files to the remote server from local sever. When the remote server uploading is completed, you are deleting the uploaded file from the local server.
View:
Create a file called
Create a file called
upload_view.ph
p in application/views
and place the uploading form HTML in this file.
I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.
No comments:
Post a Comment