note 101408 modified in function.file-put-contents by danbrown

From: Date: Wed, 15 Dec 2010 17:33:32 +0000
Subject: note 101408 modified in function.file-put-contents by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-174958@lists.php.net to get a copy of this message
To upload file from your localhost to any FTP server. pease note 'ftp_chdir' has been used instead of putting direct remote file path....in ftp_put ...remoth file should be only file name <?php $host = '*****'; $usr = '*****'; $pwd = '**********'; $local_file = './orderXML/order200.xml'; $ftp_path = 'order200.xml'; $conn_id = ftp_connect($host, 21) or die ("Cannot connect to host"); ftp_pasv($resource, true); ftp_login($conn_id, $usr, $pwd) or die("Cannot login"); // perform file upload ftp_chdir($conn_id, '/public_html/abc/'); $upload = ftp_put($conn_id, $ftp_path, $local_file, FTP_ASCII); if($upload) { $ftpsucc=1; } else { $ftpsucc=0; } // check upload status: print (!$upload) ? 'Cannot upload' : 'Upload complete'; print "\n"; // close the FTP stream ftp_close($conn_id); ?> --was-- To upload file from your localhost to any FTP server. pease note 'ftp_chdir' has been used instead of putting direct remote file path....in ftp_put ...remoth file should be only file name $host = '*****'; $usr = '*****'; $pwd = '**********'; $local_file = './orderXML/order200.xml'; $ftp_path = 'order200.xml'; $conn_id = ftp_connect($host, 21) or die ("Cannot connect to host"); ftp_pasv($resource, true); ftp_login($conn_id, $usr, $pwd) or die("Cannot login"); // perform file upload ftp_chdir($conn_id, '/public_html/abc/'); $upload = ftp_put($conn_id, $ftp_path, $local_file, FTP_ASCII); if($upload) { $ftpsucc=1; } else { $ftpsucc=0; } // check upload status: print (!$upload) ? 'Cannot upload' : 'Upload complete'; print "\n"; // close the FTP stream ftp_close($conn_id); http://php.net/manual/en/function.file-put-contents.php

« previous php.notes (#174958) next »