kat35601 Posted July 6, 2022 Share Posted July 6, 2022 I was using: $local_file = 'cit_order_download'. date('mdY_hia') .'.co'; $server_file = 'CCDATA.TXT'; $curl = curl_init(); $fh = fopen($local_file , 'w'); curl_setopt($curl, CURLOPT_URL, 'ftp://tf.ftpuat.removed.com/Outbox/' . $server_file); curl_setopt($curl, CURLOPT_USERPWD, "removed"); curl_setopt($curl, CURLOPT_PORT, 22); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($curl); fwrite($fh, $result); fclose($fh); curl_close($curl) I installed phpseclib but I can't make it work. I tried: $remoteDir = "/Outbox/"; $localDir = "./"; $connection = ssh2_connect($url); if (!ssh2_auth_password($connection, $username, $password)) throw new Exception('Unable to connect.'); if(!$stream = ssh2_sftp($connection)){ die("Unable to create stream"); } if(!$dir = opendir("ssh2.sftp://{$stream}/{$remoteDir}")){ die("Could not open dir"); } $file = 'ccdata.txt'; $remote = @fopen("ssh2.sftp://{$stream}/{$remoteDir}{$file}","r"); $local = @fopen($localDir . $localFile, "w"); $read = 0; $filesize = filesize("ssh2.sftp://{$stream}/{$remoteDir}{$file}"); while ($read < $filesize && ($buffer = fread($remote, $filesize - $read))){ $read += strlen($buffer); if(fwrite($local, $buffer) === false){ echo "Unable to write to local file: $file\n"; } fclose($local); fclose($remote); } but the filesize stat throws an error that I can't seem to get around. I use php because I download the file and read it and update our erp system with the data in the file. Quote Link to comment https://forums.phpfreaks.com/topic/315007-download-a-file-with-curl-stopped-working-when-the-supplier-update-their-security-i-need-help-in-downloading-the-file/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.