/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/ FTP access parameters: $host = 'ftp.example.org'; $usr = 'example_user'; $pwd = 'example_password'; // file to upload: $local_file = './example.txt'; $ftp_path = '/data/example.txt'; // connect to FTP server (port 21) // send access parameters // turn on passive mode transfers (some servers need this) // ftp_pasv ($conn_id, true); // perform file upload // check upload status: print (!$upload) 'Cannot upload' : 'Upload complete'; print "\n"; /* ** Chmod the file (just as example) */ // If you are using PHP4 then you need to use this code: // (because the "ftp_chmod" command is just available in PHP5+) } } // try to chmod the new file to 666 (writeable) print $ftp_path . " chmoded successfully to 666\n"; } else { print "could not chmod $file\n"; } // close the FTP stream