DATA TRANSFER Using FTP Server..

How to Establish FTP connection for fast data transfer between Mobile to PC :

Turn on your wi-fi in laptop
download and install any ftp server app (that you may trust) in your android mobile.
imp : set root directory to “internal Storage” or External Storage which ever you wish to link with FTP server and start the app FTP by pressing “Start” button.

How to Establish FTP connection for fast data transfer between Mobile to PC :

  1. Turn on your wi-fi in laptop
  2. download and install any ftp server app (that you may trust) in your android mobile.
  3. imp : set root directory to “internal Storage” or External Storage which ever you wish to link with FTP server and start the app FTP by pressing “Start” button.
  4. turn your mobile data off.
  5. Imp : turn your FTP service Internet Access Off.
  6. Open desktop/laptop file explorer and click on “My PC” and right click than select>> network locations area & select>> “add new network location”.
  7. click next on first window of setup wizard.
    8 imp : cancel the prompted “Connect to the internet” dialog popup and select the “Add Network Location” which is default minimized on taskbar.
  8. click “Next” and enter the “ftp server” address (provided by the mobile FTP Server app) and click “Next”.
    10 . keep the connection as anonymous or mention the user name provided by the FTP Server App and press “Next”.
    11 In Next Window, Name your connection or remain it default, it would not bother you anywhere else.

your FTP connection will be established When you follow all the steps mentioned above and a icon will appear on the “Network location area” showing the name of FTP you have choosen during connection setup.

Copy files to other server(ftp)

How to copy all files of a directory to a directory on other server ?
Suppose, we have to copy all files in a directory(dir/subdir) to other server directory(dir/sub) and we also have to create directory there(in case, if directory does not exist), then –

First of all make connection with Remote(other) FTP (from where we are copying the files) like –
$ftp_host = ‘host’;
$ftp_username = ‘ftp_username’;
$ftp_password = ‘ftp_password’;
$ftp_connection = ftp_connect($ftp_host);

Then, login to Remote or other ftp using –
$ftp_login = ftp_login($ftp_connection,$ftp_username,$ftp_password);

function isdir_ftp($ftp_connection,$dir){
$pushed = ftp_pwd($ftp_connection);
if($pushed!=false && @ftp_chdir($ftp_connection,$dir)){
ftp_chdir($ftp, $pushed);
return true;
}
return false;
}

Suppose, we have to copy the directory and files in public_html directory –
$server_path = “./public_html/”;
$file_path_server = “dir/subdir” ;
$server_file_path = $server_path. $file_path_server ;
$is_dir = isdir_ftp($ftp_connection, $file_path_server);
if(!$is_dir){
$dir = $file_path_server;
$dd = ”;
$d=explode(“,”,$dir);
for($i=0;$i<count($d);$i++){
$dd.=$d[$i].”/”;
//try to create dir
$dir = $dd;
$is_dir = isdir_ftp($ftp_connection, $dir);
if(!$is_dir){
if(ftp_mkdir($frp_connection, $dir)){
echo “Dir created successfully”;
}else{
echo “Error”;
}
}
}
}

Now read the files from local ftp from where we have to copy the files and the copy it –
$local_ftp_dir = ” dir/subdir “;
if ($handle = @opendir($ local_ftp_dir )) {
while (false !== ($file = readdir($handle))) {
if ($file != “.” && $file != “..”) {
$source= $ local_ftp_dir .’/’.$file;
$dest = “public_html/”.$ local_ftp_dir .’/’.$file;
$upload = ftp_put($ftp_connection, $dest, $source, FTP_BINARY);
if (!$upload) {
echo ‘FTP upload failed!’;
} else {
echo “uploaded successfully”;
}
}
}
}

ftp_close($ftp_connection);

 

 

For more related queries, please visit.
In case, if you did not find your solution or have any query/question, please contact us.
 

Copy files from other ftp or server to current ftp or server

Steps to copy all files of a particular folder from other ftp to current ftp –

First of all make connection with Remote(other) FTP (from where we are copying the files) like –
$ftp_host = ‘host’;
$ftp_username = ‘ftp_username’;
$ftp_password = ‘ftp_password’;
$ftp_connection = ftp_connect($ftp_host);

Then, login to Remote or other ftp using –
$ftp_login = ftp_login($ftp_connection,$ftp_username,$ftp_password);

After that get all files of that directory of remote ftp –
$remote_dir = ‘/dir/’;
$remote_files = ftp_nlist($ftp_connection,$remote_dir); //Array of all files from dir directory on remote server

Then, check that file exists in that directory on not –
if(count($remote_files)>0){ //There are files in remote server dir
foreach($remote_files as $remote_file){ //run loop through each file
$file_name = end(“/”,explode($remote_file)); //get file name from remote
$local_file = ‘local_dir/’.$file_name;
$server_file = $remote_file; //file from remote server
if(ftp_get($ftp_connection,$local_file,$server_file, FTP_ASCII)){
echo “File successfully copied”;
}else{
echo “error”;
}
}
}

 

For more related queries, please visit.
In case, if you did not find your solution or have any query/question, please contact us.