{"id":7777,"date":"2023-01-13T05:58:43","date_gmt":"2023-01-13T05:58:43","guid":{"rendered":"https:\/\/allabout.cc\/a1\/?p=7777"},"modified":"2023-01-13T05:58:43","modified_gmt":"2023-01-13T05:58:43","slug":"7777-2","status":"publish","type":"post","link":"https:\/\/allabout.cc\/a1\/7777-2\/","title":{"rendered":""},"content":{"rendered":"\n\/ FTP access parameters:\n$host = &#8216;ftp.example.org&#8217;;\n$usr = &#8216;example_user&#8217;;\n$pwd = &#8216;example_password&#8217;;\n \n\/\/ file to upload:\n$local_file = &#8216;.\/example.txt&#8217;;\n$ftp_path = &#8216;\/data\/example.txt&#8217;;\n \n\/\/ connect to FTP server (port 21)\n$conn_id = ftp_connect($host, 21) or die (&#8220;Cannot connect to host&#8221;);\n \n\/\/ send access parameters\nftp_login($conn_id, $usr, $pwd) or die(&#8220;Cannot login&#8221;);\n \n\/\/ turn on passive mode transfers (some servers need this)\n\/\/ ftp_pasv ($conn_id, true);\n \n\/\/ perform file upload\n$upload = ftp_put($conn_id, $ftp_path, $local_file, FTP_ASCII);\n \n\/\/ check upload status:\nprint (!$upload) &#8216;Cannot upload&#8217; : &#8216;Upload complete&#8217;;\nprint &#8220;\\n&#8221;;\n \n\/*\n** Chmod the file (just as example)\n*\/\n \n\/\/ If you are using PHP4 then you need to use this code:\n\/\/ (because the &#8220;ftp_chmod&#8221; command is just available in PHP5+)\nif (!function_exists(&#8216;ftp_chmod&#8217;)) {\n   function ftp_chmod($ftp_stream, $mode, $filename){\n        return ftp_site($ftp_stream, sprintf(&#8216;CHMOD %o %s&#8217;, $mode, $filename));\n   }\n}\n \n\/\/ try to chmod the new file to 666 (writeable)\nif (ftp_chmod($conn_id, 0666, $ftp_path) !== false) {\n    print $ftp_path . &#8221; chmoded successfully to 666\\n&#8221;;\n} else {\n    print &#8220;could not chmod $file\\n&#8221;;\n}\n \n\/\/ close the FTP stream\nftp_close($conn_id);\n","protected":false},"excerpt":{"rendered":"<p>\/ FTP access parameters: $host = &#8216;ftp.example.org&#8217;; $usr = &#8216;example_user&#8217;; $pwd = &#8216;example_password&#8217;; \/\/ file to upload: $local_file = &#8216;.\/example.txt&#8217;; $ftp_path = &#8216;\/data\/example.txt&#8217;; \/\/ connect to FTP server (port 21) $conn_id = ftp_connect($host, 21) or die (&#8220;Cannot connect to host&#8221;); \/\/ send access parameters ftp_login($conn_id, $usr, $pwd) or die(&#8220;Cannot login&#8221;); \/\/ turn on passive mode [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"hide_page_title":"","_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":""},"categories":[],"tags":[],"_links":{"self":[{"href":"https:\/\/allabout.cc\/a1\/wp-json\/wp\/v2\/posts\/7777"}],"collection":[{"href":"https:\/\/allabout.cc\/a1\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/allabout.cc\/a1\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/allabout.cc\/a1\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/allabout.cc\/a1\/wp-json\/wp\/v2\/comments?post=7777"}],"version-history":[{"count":1,"href":"https:\/\/allabout.cc\/a1\/wp-json\/wp\/v2\/posts\/7777\/revisions"}],"predecessor-version":[{"id":7778,"href":"https:\/\/allabout.cc\/a1\/wp-json\/wp\/v2\/posts\/7777\/revisions\/7778"}],"wp:attachment":[{"href":"https:\/\/allabout.cc\/a1\/wp-json\/wp\/v2\/media?parent=7777"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/allabout.cc\/a1\/wp-json\/wp\/v2\/categories?post=7777"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/allabout.cc\/a1\/wp-json\/wp\/v2\/tags?post=7777"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}