{"id":194,"date":"2019-12-01T12:40:32","date_gmt":"2019-12-01T11:40:32","guid":{"rendered":"https:\/\/lessto.dk\/cloudtofile\/?page_id=194"},"modified":"2019-12-13T21:02:28","modified_gmt":"2019-12-13T20:02:28","slug":"lessto-cloudtofile-wordpress-php-example","status":"publish","type":"page","link":"https:\/\/lessto.dk\/cloudtofile\/lessto-cloudtofile-wordpress-php-example\/","title":{"rendered":"lessto &#8211; cloudtofile &#8211; wordpress PHP &#8211; example"},"content":{"rendered":"<h1><span style=\"font-family: Impact, Charcoal, sans-serif; font-size: 40px; color: rgba(54, 162, 235, 0.8);\">lessto CloudToFile<\/span><\/h1>\n<p>Demo of WordPress PHP template, where data is transferred to and from a FTP site. A simple cloud to file function.<\/p>\n<p><a href=\"https:\/\/lessto.dk\/cloudtofile\/lessto-bc365-spring-code-example-eng\/\">Code for Business Central 365 Spring Edition (14)<\/a><br \/>\n <a href=\"https:\/\/lessto.dk\/cloudtofile\/lessto-bc365-wave-2-code-example-eng\/\">Code for Business Central 365 Wave 2 (15)<\/a><\/p>\n<p>If you take all the WP stuff out, the code works in plain PHP.<\/p>\n<p>Feel free to use the code if you have projects with http request, JSON conversion and BASE64.<\/p>\n<p>The keypoints is to change the APIKEY and ftp information, this can be done in the code. In customer code it should be saved in a table.<\/p>\n<p>Here is the code.<\/p>\n<p>The working demo where this code comes from is here.<\/p>\n<p><a href=\"https:\/\/lessto.dk\/cloudtofile\/lessto-ftp-com\/\">WordPress PHP cloud to file demo<\/a><\/p>\n<p><\/p>\n<pre>\r\n<div>&lt;?php<\/div>\r\n<div>\/**<\/div>\r\n<div>\u00a0*\u00a0Template\u00a0Name:\u00a0lessto\u00a0-\u00a0cloud\u00a0-\u00a0ftp\u00a0-\u00a0com<\/div>\r\n<div>\u00a0*\/<\/div>\r\n<div><\/div>\r\n<div>get_header();<\/div>\r\n<div>$website\u00a0=\u00a0'https:\/\/lessto.dk\/cloudtofile\/lessto-ftp-connect';<\/div>\r\n<div>$apikey = '&lt;Your API key from lessto Cloud To File&gt;';<\/div>\r\n<div>$user = '&lt;FTP server user name&gt;';<\/div>\r\n<div>$pass = '&lt;FTP server user password&gt;';<\/div>\r\n<div>$ftpserver = '&lt;FTP server name&gt;';<\/div>\r\n<div>$ftpdir = '&lt;FTP server directory&gt;';<\/div>\r\n<div><\/div>\r\n<div>\r\n\r\n?&gt;\r\n<div>&lt;html&gt;<\/div>\r\n<div>&lt;style&gt;<\/div>\r\n<div>.spacemobile\u00a0{<\/div>\r\n<div>\u00a0\u00a0display:\u00a0none;<\/div>\r\n<div>}<\/div>\r\n<div>@media\u00a0(max-width:\u00a0800px)\u00a0{<\/div>\r\n<div><\/div>\r\n<div>\u00a0\u00a0.spacemobile\u00a0{<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0display:\u00a0block;<\/div>\r\n<div>\u00a0\u00a0}<\/div>\r\n<div>}<\/div>\r\n<div>&lt;\/style&gt;<\/div>\r\n<div>&lt;body&gt;<\/div>\r\n<div>&lt;br&gt;<\/div>\r\n<div>&lt;div\u00a0class=\"spacemobile\"&gt;&lt;br&gt;&lt;br&gt;&lt;\/div&gt;<\/div>\r\n<div>&lt;span\u00a0style=\"font-family:Impact,\u00a0Charcoal,\u00a0sans-serif;font-size:40px;color:rgba(54,\u00a0162,\u00a0235,\u00a00.8);\"&gt;lessto\u00a0CloudToFile&lt;\/span&gt;<\/div>\r\n<div>\u00a0&lt;br&gt;<\/div>\r\n<div>\u00a0&lt;h2&gt;Demo\u00a0of\u00a0website\u00a0sending\u00a0and\u00a0recieving\u00a0FTP\u00a0files.&lt;\/h2&gt;<\/div>\r\n<div>&lt;p&gt;It\u00a0uses\u00a0the\u00a0four\u00a0simple\u00a0commands\u00a0in\u00a0lessto\u00a0CloudToFile&lt;\/p&gt;<\/div>\r\n<div>&lt;br&gt;<\/div>\r\n<div>&lt;form\u00a0method\u00a0=\u00a0\"POST\"&gt;<\/div>\r\n<div>&lt;input\u00a0type\u00a0=\u00a0\"submit\"\u00a0name\u00a0=\u00a0\"action\"\u00a0class=\"less-submit\"\u00a0value\u00a0=\u00a0'list'&gt;<\/div>\r\n<div>&lt;input\u00a0type\u00a0=\u00a0\"submit\"\u00a0name\u00a0=\u00a0\"action\"\u00a0class=\"less-submit\"\u00a0value\u00a0=\u00a0'send'&gt;<\/div>\r\n<div>&lt;input\u00a0type\u00a0=\u00a0\"submit\"\u00a0name\u00a0=\u00a0\"action\"\u00a0class=\"less-submit\"\u00a0value\u00a0=\u00a0'get'&gt;<\/div>\r\n<div>&lt;input\u00a0type\u00a0=\u00a0\"submit\"\u00a0name\u00a0=\u00a0\"action\"\u00a0class=\"less-submit\"\u00a0value\u00a0=\u00a0'delete'&gt;<\/div>\r\n<div>&lt;\/form&gt;<\/div>\r\n<div>&lt;?php<\/div>\r\n<div>if\u00a0($_POST[\"action\"]\u00a0==\u00a0'list')\u00a0{<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0$action\u00a0=\u00a0'list';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0$postdata\u00a0=\u00a0http_build_query(<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0array(<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'apikey'\u00a0=&gt;\u00a0$apikey,<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'action'\u00a0=&gt;\u00a0$action,<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'user'\u00a0=&gt;\u00a0$user,<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'pass'\u00a0=&gt;\u00a0$pass,<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'ftpserver'\u00a0=&gt;\u00a0$ftpserver,<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'ftpdir'\u00a0=&gt;\u00a0$ftpdir)<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0);<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0$post\u00a0=\u00a0array('http'\u00a0=&gt;<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0array(<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'method'\u00a0\u00a0=&gt;\u00a0'POST',<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'header'\u00a0\u00a0=&gt;\u00a0'Content-Type:\u00a0application\/x-www-form-urlencoded',<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'content'\u00a0=&gt;\u00a0$postdata)<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0);<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0$postcontext\u00a0\u00a0=\u00a0stream_context_create($post);<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0$result\u00a0=\u00a0@file_get_contents($website,\u00a0false,\u00a0$postcontext);<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0if\u00a0(!$result)\u00a0{<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0echo\u00a0'&lt;br&gt;';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0echo\u00a0'errorcode=70';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0echo\u00a0'&lt;br&gt;';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0echo\u00a0'errortext=No\u00a0connection\u00a0to\u00a0lessto\u00a0CloudToFile';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0echo\u00a0'&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0get_footer();<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0die;<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0}<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0$resultarray\u00a0=\u00a0@json_decode($result);<\/div>\r\n<div><\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0if\u00a0($resultarray-&gt;errorno\u00a0!=\u00a0'')\u00a0{<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0echo\u00a0'&lt;br&gt;';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0echo\u00a0'errorcode='.$resultarray-&gt;errorno;<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0echo\u00a0'&lt;br&gt;';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0echo\u00a0'errortext='.$resultarray-&gt;errortext;<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0echo\u00a0'&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0get_footer();<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0die;<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0}<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0echo\u00a0'&lt;br&gt;';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0echo\u00a0'status='.$resultarray-&gt;status;<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0echo\u00a0'&lt;br&gt;';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0echo\u00a0'&lt;br&gt;';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0if\u00a0(count($resultarray)\u00a0&gt;\u00a00)\u00a0{<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0foreach\u00a0($resultarray\u00a0as\u00a0$key=&gt;$value)\u00a0{<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if\u00a0(strpos($key,\u00a0'file')\u00a0!==\u00a0false)\u00a0{<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$filelist\u00a0=\u00a0$filelist.$value;<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$filelist\u00a0=\u00a0$filelist.'&lt;br&gt;';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0}<\/div>\r\n<div><\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0echo\u00a0'Filelist:';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0echo\u00a0'&lt;br&gt;';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0echo\u00a0'&lt;br&gt;';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0echo\u00a0$filelist;<\/div>\r\n<div>}<\/div>\r\n<div>if\u00a0($_POST[\"action\"]\u00a0==\u00a0'send')\u00a0{<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0$action\u00a0=\u00a0'send';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0$filecontent\u00a0=<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0'\"1122332\",\"Furniture\u00a0store\"&lt;br&gt;'.<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0'\"1122311\",\"Car\u00a0store\"&lt;br&gt;'.<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0'\"1122322\",\"Tree\u00a0store\"&lt;br&gt;'.<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0'\"1119932\",\"Cheese\u00a0store\"&lt;br&gt;'.<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0'\"9482843\",\"Bicycle\u00a0store\"&lt;br&gt;'.<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0'\"9922133\",\"Gun\u00a0store\"';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0$base64\u00a0=\u00a0base64_encode($filecontent);<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0$filename\u00a0=\u00a0'testfile.txt';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0$postdata\u00a0=\u00a0http_build_query(<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0array(<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'apikey'\u00a0=&gt;\u00a0$apikey,<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'action'\u00a0=&gt;\u00a0$action,<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'user'\u00a0=&gt;\u00a0$user,<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'pass'\u00a0=&gt;\u00a0$pass,<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'ftpserver'\u00a0=&gt;\u00a0$ftpserver,<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'ftpdir'\u00a0=&gt;\u00a0$ftpdir,<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'ftpfilename'\u00a0=&gt;\u00a0$filename,<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'base64'\u00a0=&gt;\u00a0$base64)<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0);<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0$post\u00a0=\u00a0array('http'\u00a0=&gt;<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0array(<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'method'\u00a0\u00a0=&gt;\u00a0'POST',<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'header'\u00a0\u00a0=&gt;\u00a0'Content-Type:\u00a0application\/x-www-form-urlencoded',<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'content'\u00a0=&gt;\u00a0$postdata)<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0);<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0$postcontext\u00a0\u00a0=\u00a0stream_context_create($post);<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0$result\u00a0=\u00a0@file_get_contents($website,\u00a0false,\u00a0$postcontext);<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0if\u00a0(!$result)\u00a0{<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0echo\u00a0'&lt;br&gt;';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0echo\u00a0'errorcode=70';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0echo\u00a0'&lt;br&gt;';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0echo\u00a0'errortext=No\u00a0connection\u00a0to\u00a0lessto\u00a0CloudToFile';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0echo\u00a0'&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0get_footer();<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0die;<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0}<\/div>\r\n<div><\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0$resultarray\u00a0=\u00a0@json_decode($result);<\/div>\r\n<div><\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0if\u00a0($resultarray-&gt;errorno\u00a0!=\u00a0'')\u00a0{<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0echo\u00a0'&lt;br&gt;';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0echo\u00a0'errorcode='.$resultarray-&gt;errorno;<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0echo\u00a0'&lt;br&gt;';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0echo\u00a0'errortext='.$resultarray-&gt;errortext;<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0echo\u00a0'&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0get_footer();<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0die;<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0}<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0echo\u00a0'&lt;br&gt;';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0echo\u00a0'status='.$resultarray-&gt;status;<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0echo\u00a0'&lt;br&gt;';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0echo\u00a0'&lt;br&gt;';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0echo\u00a0'Filesend:\u00a0OK';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0echo\u00a0'&lt;br&gt;';<\/div>\r\n<div>}<\/div>\r\n<div>if\u00a0($_POST[\"action\"]\u00a0==\u00a0'get')\u00a0{<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0$action\u00a0=\u00a0'get';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0$filename\u00a0=\u00a0'testfile.txt';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0$postdata\u00a0=\u00a0http_build_query(<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0array(<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'apikey'\u00a0=&gt;\u00a0$apikey,<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'action'\u00a0=&gt;\u00a0$action,<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'user'\u00a0=&gt;\u00a0$user,<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'pass'\u00a0=&gt;\u00a0$pass,<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'ftpserver'\u00a0=&gt;\u00a0$ftpserver,<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'ftpdir'\u00a0=&gt;\u00a0$ftpdir,<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'ftpfilename'\u00a0=&gt;\u00a0$filename)<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0);<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0$post\u00a0=\u00a0array('http'\u00a0=&gt;<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0array(<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'method'\u00a0\u00a0=&gt;\u00a0'POST',<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'header'\u00a0\u00a0=&gt;\u00a0'Content-Type:\u00a0application\/x-www-form-urlencoded',<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'content'\u00a0=&gt;\u00a0$postdata)<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0);<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0$postcontext\u00a0\u00a0=\u00a0stream_context_create($post);<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0$result\u00a0=\u00a0@file_get_contents($website,\u00a0false,\u00a0$postcontext);<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0if\u00a0(!$result)\u00a0{<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0echo\u00a0'&lt;br&gt;';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0echo\u00a0'errorcode=70';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0echo\u00a0'&lt;br&gt;';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0echo\u00a0'errortext=No\u00a0connection\u00a0to\u00a0lessto\u00a0CloudToFile';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0die;<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0}<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0$resultarray\u00a0=\u00a0@json_decode($result);<\/div>\r\n<div><\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0$res_errorcode\u00a0=\u00a0$resultarray-&gt;errorno;<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0$res_errortext\u00a0=\u00a0$resultarray-&gt;errortext;<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0if\u00a0($res_errorcode\u00a0!=\u00a0'')\u00a0{<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0echo\u00a0'&lt;br&gt;';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0echo\u00a0'errorcode='.$res_errorcode;<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0echo\u00a0'&lt;br&gt;';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0echo\u00a0'errortext='.$res_errortext;<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0echo\u00a0'&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0get_footer();<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0die;<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0}<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0echo\u00a0'&lt;br&gt;';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0echo\u00a0'status='.$resultarray-&gt;status;<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0echo\u00a0'&lt;br&gt;';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0echo\u00a0'&lt;br&gt;';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0echo\u00a0'Fileget:';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0echo\u00a0'&lt;br&gt;';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0echo\u00a0'&lt;br&gt;';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0$filecontent\u00a0=\u00a0base64_decode($resultarray-&gt;base64);<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0echo\u00a0$filecontent;<\/div>\r\n<div>}<\/div>\r\n<div>if\u00a0($_POST[\"action\"]\u00a0==\u00a0'delete')\u00a0{<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0$action\u00a0=\u00a0'delete';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0$filename\u00a0=\u00a0'testfile.txt';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0$postdata\u00a0=\u00a0http_build_query(<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0array(<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'apikey'\u00a0=&gt;\u00a0$apikey,<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'action'\u00a0=&gt;\u00a0$action,<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'user'\u00a0=&gt;\u00a0$user,<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'pass'\u00a0=&gt;\u00a0$pass,<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'ftpserver'\u00a0=&gt;\u00a0$ftpserver,<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'ftpdir'\u00a0=&gt;\u00a0$ftpdir,<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'ftpfilename'\u00a0=&gt;\u00a0$filename)<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0);<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0$post\u00a0=\u00a0array('http'\u00a0=&gt;<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0array(<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'method'\u00a0\u00a0=&gt;\u00a0'POST',<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'header'\u00a0\u00a0=&gt;\u00a0'Content-Type:\u00a0application\/x-www-form-urlencoded',<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'content'\u00a0=&gt;\u00a0$postdata)<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0);<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0$postcontext\u00a0\u00a0=\u00a0stream_context_create($post);<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0$result\u00a0=\u00a0@file_get_contents($website,\u00a0false,\u00a0$postcontext);<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0if\u00a0(!$result)\u00a0{<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0echo\u00a0'&lt;br&gt;';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0echo\u00a0'errorcode=70';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0echo\u00a0'&lt;br&gt;';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0echo\u00a0'errortext=No\u00a0connection\u00a0to\u00a0lessto\u00a0CloudToFile';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0echo\u00a0'&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0get_footer();<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0die;<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0}<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0$resultarray\u00a0=\u00a0json_decode($result);<\/div>\r\n<div><\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0if\u00a0($resultarray-&gt;errorno\u00a0!=\u00a0'')\u00a0{<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0echo\u00a0'&lt;br&gt;';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0echo\u00a0'errorcode='.$resultarray-&gt;errorno;<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0echo\u00a0'&lt;br&gt;';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0echo\u00a0'errortext='.$resultarray-&gt;errortext;<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0echo\u00a0'&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0get_footer();<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0die;<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0}<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0echo\u00a0'&lt;br&gt;';<\/div>\r\n<div>\u00a0\u00a0\u00a0\u00a0echo\u00a0'status='.$resultarray-&gt;status;<\/div>\r\n<div>}<\/div>\r\n<div>get_footer();<\/div>\r\n<\/div>\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>lessto CloudToFile Demo of WordPress PHP template, where data is transferred to and from a FTP site. A simple cloud to file function. Code for Business Central 365 Spring Edition (14) Code for Business Central 365 Wave 2 (15) If you take all the WP stuff out, the code works in plain PHP. Feel free &#8230; <a title=\"lessto &#8211; cloudtofile &#8211; wordpress PHP &#8211; example\" class=\"read-more\" href=\"https:\/\/lessto.dk\/cloudtofile\/lessto-cloudtofile-wordpress-php-example\/\" aria-label=\"More on lessto &#8211; cloudtofile &#8211; wordpress PHP &#8211; example\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v15.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>lessto - cloudtofile - wordpress PHP - example - CloudToFile<\/title>\n<meta name=\"description\" content=\"Demo of WordPress PHP template, where data i transferred to and from a FTP site.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/lessto.dk\/cloudtofile\/lessto-cloudtofile-wordpress-php-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"lessto - cloudtofile - wordpress PHP - example - CloudToFile\" \/>\n<meta property=\"og:description\" content=\"Demo of WordPress PHP template, where data i transferred to and from a FTP site.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/lessto.dk\/cloudtofile\/lessto-cloudtofile-wordpress-php-example\/\" \/>\n<meta property=\"og:site_name\" content=\"CloudToFile\" \/>\n<meta property=\"article:modified_time\" content=\"2019-12-13T20:02:28+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" value=\"Written by\">\n\t<meta name=\"twitter:data1\" value=\"lssto\">\n\t<meta name=\"twitter:label2\" value=\"Est. reading time\">\n\t<meta name=\"twitter:data2\" value=\"5 minutes\">\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/lessto.dk\/cloudtofile\/#website\",\"url\":\"https:\/\/lessto.dk\/cloudtofile\/\",\"name\":\"CloudToFile\",\"description\":\"Cloud FTP and Print service\",\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/lessto.dk\/cloudtofile\/lessto-cloudtofile-wordpress-php-example\/#webpage\",\"url\":\"https:\/\/lessto.dk\/cloudtofile\/lessto-cloudtofile-wordpress-php-example\/\",\"name\":\"lessto - cloudtofile - wordpress PHP - example - CloudToFile\",\"isPartOf\":{\"@id\":\"https:\/\/lessto.dk\/cloudtofile\/#website\"},\"datePublished\":\"2019-12-01T11:40:32+00:00\",\"dateModified\":\"2019-12-13T20:02:28+00:00\",\"description\":\"Demo of WordPress PHP template, where data i transferred to and from a FTP site.\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/lessto.dk\/cloudtofile\/lessto-cloudtofile-wordpress-php-example\/\"]}]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/lessto.dk\/cloudtofile\/wp-json\/wp\/v2\/pages\/194"}],"collection":[{"href":"https:\/\/lessto.dk\/cloudtofile\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/lessto.dk\/cloudtofile\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/lessto.dk\/cloudtofile\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lessto.dk\/cloudtofile\/wp-json\/wp\/v2\/comments?post=194"}],"version-history":[{"count":9,"href":"https:\/\/lessto.dk\/cloudtofile\/wp-json\/wp\/v2\/pages\/194\/revisions"}],"predecessor-version":[{"id":216,"href":"https:\/\/lessto.dk\/cloudtofile\/wp-json\/wp\/v2\/pages\/194\/revisions\/216"}],"wp:attachment":[{"href":"https:\/\/lessto.dk\/cloudtofile\/wp-json\/wp\/v2\/media?parent=194"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}