PHP

UPLOAD & DOWNLOAD THROUGH FTP IN PHP

CONNECT TO FTP SERVER $ftp = ftp_connect("HOST");

LOGIN TO SERVER if (ftp_login($ftp, "USER", "PASS") {   DOWNLOAD FILE   ftp_get($ftp, "DESTINATION",   "SOURCE", FTP_BINARY);     UPLOAD FILE   ftp_put($ftp, "DESTINATION",   "SOURCE", FTP_BINARY) }

CLOSE CONNECTION ftp_close($ftp);

FTP UPLOAD & DOWNLOAD

01

INIT CURL + OPEN FILE $curl = curl_init(); $file = fopen("DESTINATION", "w");

CURL OPTIONS curl_setopt_array($curl, [   CURLOPT_URL => "HOST/FILE",    CURLOPT_USERPWD =>      "USER:PASS",    CURLOPT_RETURNTRANSFER => 1,    CURLOPT_FILE => $file ]);

CURL FTP DOWNLOAD curl_exec($curl); curl_close($curl); fclose($file);

DOWNLOAD WITH CURL FTP

02

INIT CURL + OPEN FILE $curl = curl_init(); $file = fopen("SOURCE", "r");

CURL OPTIONS curl_setopt_array($curl, [   CURLOPT_URL => "HOST/FILE",    CURLOPT_USERPWD =>     "USER:PASS",    CURLOPT_UPLOAD => 1,    CURLOPT_INFILE => $file,    CURLOPT_INFILESIZE =>      filesize(SOURCE) ]);

CURL FTP UPLOAD + CLOSE curl_exec($curl); curl_close($curl); fclose($file);

UPLOAD WITH CURL FTP

03