Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $host = 'ftp.example.org';
- $usr = 'example_user';
- $pwd = 'example_password';
- $local_file = './example.txt';
- $ftp_path = '/data/example.txt';
- $conn_id = ftp_connect($host, 21) or die ("Cannot connect to host");
- ftp_login($conn_id, $usr, $pwd) or die("não foi possível conectar ao FTP");
- $upload = ftp_put($conn_id, $ftp_path, $local_file, FTP_ASCII);
- print (!$upload) ? 'Erro no Upload' : 'Upload completo';
- print "\n";
- if (!function_exists('ftp_chmod')) {
- function ftp_chmod($ftp_stream, $mode, $filename){
- return ftp_site($ftp_stream, sprintf('CHMOD %o %s', $mode, $filename));
- }
- }
- if (ftp_chmod($conn_id, 0666, $ftp_path) !== false) {
- print $ftp_path . " chmoded successfully to 666\n";
- } else {
- print "could not chmod $file\n";
- }
- ftp_close($conn_id);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement